Skip to content

Commit 9648dd1

Browse files
authored
Add files via upload
0 parents  commit 9648dd1

9 files changed

+401
-0
lines changed

download_model.json

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"run": [{
3+
"method": "input",
4+
"params": {
5+
"title": "Download a model",
6+
"description": "Enter the model download url",
7+
"form": [{
8+
"key": "url",
9+
"title": "url"
10+
}]
11+
}
12+
}, {
13+
"method": "fs.download",
14+
"params": {
15+
"url": "{{input.url}}",
16+
"path": "automatic/models/Stable-diffusion"
17+
}
18+
}, {
19+
"method": "input",
20+
"params": {
21+
"title": "Success!",
22+
"description": "Model download complete. Now refresh the models dropdown in the web ui to vies the updated list."
23+
}
24+
}, {
25+
"method": "browser.open",
26+
"params": {
27+
"uri": "/"
28+
}
29+
}]
30+
}

icon.png

22.7 KB
Loading

index.js

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
const os = require('os')
2+
const fs = require('fs')
3+
const path = require('path')
4+
class Automatic {
5+
// set up COMMANDLINE_ARGS inside webui-user.sh or webui.bat
6+
async config(req, ondata, kernel) {
7+
let graphics = await kernel.system.graphics()
8+
let platform = os.platform()
9+
let vendor = graphics.controllers[0].vendor
10+
ondata({ raw: `\r\nVendor: ${vendor}\r\n` })
11+
12+
let legacy = req.params && req.params.legacy
13+
// if legacy => ""
14+
// if SDXL (not legacy) => "--no-download-sd-model"
15+
let defaultArgs = (legacy ? "" : "--no-download-sd-model ")
16+
if (platform === 'darwin') {
17+
if (/apple/i.test(vendor)) {
18+
defaultArgs += "--skip-torch-cuda-test --upcast-sampling --use-cpu interrogate --no-half --api"
19+
} else {
20+
defaultArgs += "--skip-torch-cuda-test --upcast-sampling --use-cpu all --no-half --api"
21+
}
22+
let text = await fs.promises.readFile(path.resolve(__dirname, "automatic", "webui-user.sh"), "utf8")
23+
let re = /^(#?)(export COMMANDLINE_ARGS=)(.+)$/m
24+
let newtext = text.replace(re, `$2"${defaultArgs}"`)
25+
await fs.promises.writeFile(path.resolve(__dirname, "automatic", "webui-user.sh"), newtext)
26+
} else if (platform === 'win32') {
27+
defaultArgs += "--xformers --no-half-vae --api"
28+
let text = await fs.promises.readFile(path.resolve(__dirname, "automatic", "webui.bat"), "utf8")
29+
let re = /^(set COMMANDLINE_ARGS=)(.*)$/m
30+
let newtext = text.replace(re, `$1${defaultArgs}`)
31+
await fs.promises.writeFile(path.resolve(__dirname, "automatic", "webui.bat"), newtext)
32+
} else {
33+
// linux
34+
if (/amd/i.test(vendor)) {
35+
// lshqqytiger
36+
defaultArgs += "--precision full --no-half-vae --xformers --api"
37+
} else {
38+
defaultArgs += "--xformers --no-half-vae --api"
39+
}
40+
let text = await fs.promises.readFile(path.resolve(__dirname, "automatic", "webui-user.sh"), "utf8")
41+
let re = /^(#?)(export COMMANDLINE_ARGS=)(.+)$/m
42+
let newtext = text.replace(re, `$2"${defaultArgs}"`)
43+
await fs.promises.writeFile(path.resolve(__dirname, "automatic", "webui-user.sh"), newtext)
44+
}
45+
}
46+
}
47+
module.exports = Automatic

install.js

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
const path = require("path")
2+
const os = require('os')
3+
module.exports = async (kernel) => {
4+
const platform = os.platform()
5+
const graphics = await kernel.system.graphics()
6+
const vendor = graphics.controllers[0].vendor
7+
let setup
8+
if (platform === "darwin") {
9+
setup = [{
10+
method: "shell.run",
11+
params: { message: "brew install cmake protobuf rust [email protected] git wget", },
12+
//params: { message: "brew install protobuf rust wget", },
13+
}, {
14+
method: "shell.run",
15+
params: { message: "git clone https://github.com/vladmandic/automatic automatic", path: path.resolve(__dirname) },
16+
}]
17+
} else {
18+
if (/amd/i.test(vendor)) {
19+
if (platform === 'win32') {
20+
setup = [{
21+
method: "shell.run",
22+
params: { message: "git clone https://github.com/vladmandic/automatic automatic", path: path.resolve(__dirname) },
23+
}]
24+
} else {
25+
setup = [{
26+
method: "shell.run",
27+
params: { message: "git clone https://github.com/vladmandic/automatic automatic", path: path.resolve(__dirname) },
28+
}]
29+
}
30+
} else {
31+
setup = [{
32+
method: "shell.run",
33+
params: { message: "git clone https://github.com/vladmandic/automatic automatic", path: path.resolve(__dirname) },
34+
}]
35+
}
36+
}
37+
38+
let run = setup.concat([{
39+
"uri": "./index.js",
40+
"method": "config",
41+
}, {
42+
"method": "self.set",
43+
"params": {
44+
"automatic/ui-config.json": {
45+
"txt2img/Width/value": 1024,
46+
"txt2img/Height/value": 1024,
47+
}
48+
}
49+
}, {
50+
"method": "notify",
51+
"params": {
52+
"html": "<b>Downloading Model</b><br>Downloading the Stable Diffusion XL 1.0 model..."
53+
}
54+
}, {
55+
"method": "fs.download",
56+
"params": {
57+
"url": "https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0.safetensors",
58+
"path": "automatic/models/Stable-diffusion/sd_xl_base_1.0.safetensors"
59+
}
60+
}, {
61+
"method": "fs.download",
62+
"params": {
63+
"url": "https://huggingface.co/stabilityai/stable-diffusion-xl-refiner-1.0/resolve/main/sd_xl_refiner_1.0.safetensors",
64+
"path": "automatic/models/Stable-diffusion/sd_xl_refiner_1.0.safetensors"
65+
}
66+
// }, {
67+
// "method": "fs.download",
68+
// "params": {
69+
// //"url": "https://huggingface.co/madebyollin/sdxl-vae-fp16-fix/resolve/main/sdxl_vae.safetensors",
70+
// //"path": "automatic/models/Stable-diffusion/sd_xl_base_0.9.vae.safetensors"
71+
// "url": "https://huggingface.co/stabilityai/sdxl-vae/blob/main/sdxl_vae.safetensors",
72+
// "path": "automatic/models/Stable-diffusion/sd_xl_base_1.0.vae.safetensors"
73+
// }
74+
}, {
75+
"method": "notify",
76+
"params": {
77+
"html": "<b>Installing webui</b><br>All SDXL 1.0 models downloaded successfully. Now setting up Automatic/stable-diffusion-webui..."
78+
}
79+
}, {
80+
"method": "shell.start",
81+
"params": {
82+
"path": "automatic",
83+
"env": {
84+
"HF_HOME": "../huggingface"
85+
},
86+
}
87+
}, {
88+
"method": "shell.enter",
89+
"params": {
90+
"message": "{{os.platform() === 'win32' ? 'webui.bat' : 'bash webui.sh -f'}}",
91+
"on": [{
92+
"event": "/(http:\/\/[0-9.:]+)/",
93+
"return": "{{event.matches[0][1]}}"
94+
}]
95+
}
96+
}, {
97+
"method": "local.set",
98+
"params": {
99+
"url": "{{input}}"
100+
}
101+
}, {
102+
"method": "input",
103+
"params": {
104+
"title": "Install Success",
105+
"description": "Go back to the dashboard and launch the app!"
106+
}
107+
}, {
108+
"method": "browser.open",
109+
"params": {
110+
"uri": "/?selected=Stable Diffusion web UI"
111+
}
112+
}])
113+
return { run }
114+
}

install_legacy.js

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
const path = require("path")
2+
const os = require('os')
3+
module.exports = async (kernel) => {
4+
const platform = os.platform()
5+
const graphics = await kernel.system.graphics()
6+
const vendor = graphics.controllers[0].vendor
7+
if (platform === "darwin") {
8+
setup = [{
9+
method: "shell.run",
10+
params: { message: "brew install cmake protobuf rust [email protected] git wget", },
11+
//params: { message: "brew install protobuf rust wget", },
12+
}, {
13+
method: "shell.run",
14+
params: { message: "git clone https://github.com/vladmandic/automatic automatic", path: path.resolve(__dirname) },
15+
}]
16+
} else {
17+
if (/amd/i.test(vendor)) {
18+
if (platform === 'win32') {
19+
setup = [{
20+
method: "shell.run",
21+
params: { message: "git clone https://github.com/vladmandic/automatic automatic", path: path.resolve(__dirname) },
22+
}]
23+
} else {
24+
setup = [{
25+
method: "shell.run",
26+
params: { message: "git clone https://github.com/vladmandic/automatic automatic", path: path.resolve(__dirname) },
27+
}]
28+
}
29+
} else {
30+
setup = [{
31+
method: "shell.run",
32+
params: { message: "git clone https://github.com/vladmandic/automatic automatic", path: path.resolve(__dirname) },
33+
}]
34+
}
35+
}
36+
let run = setup.concat([{
37+
"uri": "./index.js",
38+
"method": "config",
39+
"params": {
40+
"legacy": true
41+
}
42+
}, {
43+
"method": "shell.start",
44+
"params": {
45+
"path": "automatic",
46+
"env": {
47+
"HF_HOME": "../huggingface"
48+
},
49+
}
50+
}, {
51+
"method": "shell.enter",
52+
"params": {
53+
"message": "{{os.platform() === 'win32' ? 'webui.bat' : 'bash webui.sh -f'}}",
54+
"on": [{
55+
"event": "/(http:\/\/[0-9.:]+)/",
56+
"return": "{{event.matches[0][1]}}"
57+
}]
58+
}
59+
}, {
60+
"method": "local.set",
61+
"params": {
62+
"url": "{{input}}"
63+
}
64+
}, {
65+
"method": "input",
66+
"params": {
67+
"title": "Install Success",
68+
"description": "Go back to the dashboard and launch the app!"
69+
}
70+
}, {
71+
"method": "browser.open",
72+
"params": {
73+
"uri": "/?selected=Stable Diffusion web UI"
74+
}
75+
}])
76+
return { run }
77+
}

pinokio.js

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
const os = require('os')
2+
const fs = require('fs')
3+
const path = require("path")
4+
const exists = (filepath) => {
5+
return new Promise(r=>fs.access(filepath, fs.constants.F_OK, e => r(!e)))
6+
}
7+
module.exports = {
8+
title: "SDNext-Vladmandic UI",
9+
description: "One-click launcher for SDNext-Vladmandic Stable Diffusion web UI",
10+
icon: "icon.png",
11+
update: async (kernel) => {
12+
return "update.json"
13+
},
14+
// start: display if
15+
// start: async (kernel) => {
16+
// let installed = await exists(path.resolve(__dirname, "automatic", "venv"))
17+
// if (installed) {
18+
// return "start.json"
19+
// }
20+
// },
21+
menu: async (kernel) => {
22+
let installed = await exists(path.resolve(__dirname, "automatic", "venv"))
23+
if (installed) {
24+
let session = (await kernel.loader.load(path.resolve(__dirname, "session.json"))).resolved
25+
return [{
26+
when: "start.js",
27+
on: "<i class='fa-solid fa-spin fa-circle-notch'></i> Running",
28+
type: "label",
29+
href: "start.js"
30+
}, {
31+
when: "start.js",
32+
off: "<i class='fa-solid fa-power-off'></i> Launch",
33+
href: "start.js?fullscreen=true&run=true",
34+
}, {
35+
when: "start.js",
36+
on: "<i class='fa-solid fa-rocket'></i> Open Web UI",
37+
href: (session && session.url ? session.url : "http://127.0.0.1:7860"),
38+
target: "_blank"
39+
}, {
40+
when: "start.js",
41+
on: "<i class='fa-solid fa-desktop'></i> Server",
42+
href: "start.js?fullscreen=true"
43+
// }, {
44+
// html: "<i class='fa-solid fa-plug'></i> Reinstall",
45+
// href: "install.js"
46+
}, {
47+
html: '<i class="fa-solid fa-gear"></i> Configure',
48+
href: (os.platform() === 'win32' ? "automatic/webui.bat#L6" : "automatic/webui-user.sh#L13")
49+
}]
50+
} else {
51+
return [{
52+
html: '<i class="fa-solid fa-plug"></i> Install Stable Diffusion XL',
53+
type: "link",
54+
href: "install.js?run=true&fullscreen=true"
55+
}, {
56+
html: '<i class="fa-solid fa-plug"></i> Install Stable Diffusion 1.5',
57+
type: "link",
58+
href: "install_legacy.js?run=true&fullscreen=true"
59+
}, {
60+
html: '<i class="fa-solid fa-gear"></i> Configure',
61+
type: "link",
62+
href: (os.platform() === 'win32' ? "automatic/webui.bat#L6" : "automatic/webui-user.sh#L13")
63+
}]
64+
}
65+
}
66+
}

session.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"url": "http://127.0.0.1:7860"
3+
}

start.js

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
const os = require('os')
2+
module.exports = async (kernel) => {
3+
return {
4+
run: [{
5+
method: "shell.start",
6+
params: {
7+
path: "automatic",
8+
env: {
9+
HF_HOME: "../huggingface"
10+
},
11+
}
12+
}, {
13+
method: "shell.enter",
14+
params: {
15+
message: "{{os.platform() === 'win32' ? 'webui.bat' : 'bash webui.sh -f'}}",
16+
on: [{
17+
event: "/(http:\/\/127.0.0.1:[0-9]+)/",
18+
return: "{{event.matches[0][1]}}"
19+
}]
20+
}
21+
}, {
22+
method: "self.set",
23+
params: {
24+
"session.json": {
25+
"url": "{{input}}"
26+
}
27+
28+
}
29+
}, {
30+
method: "browser.open",
31+
params: {
32+
uri: "/?selected=Stable Diffusion web UI"
33+
}
34+
// }, {
35+
// method: "notify",
36+
// params: {
37+
// html: "Successfully launched. Go to the dashboard to open the web ui",
38+
// href: "/?selected=Stable Diffusion web UI"
39+
// }
40+
}, {
41+
method: "process.wait"
42+
}]
43+
}
44+
}

0 commit comments

Comments
 (0)