This commit is contained in:
gepeto
2024-08-06 02:32:51 -04:00
commit c6151a15ca
11 changed files with 267 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
node_modules
.DS_Store

15
app.py Normal file
View File

@@ -0,0 +1,15 @@
import gradio as gr
import torch
from diffusers import DiffusionPipeline
import devicetorch
device = devicetorch.get(torch)
pipe = DiffusionPipeline.from_pretrained("stabilityai/sdxl-turbo").to(device)
def generate_image(prompt):
return pipe(
prompt,
num_inference_steps=2,
strength=0.5,
guidance_scale=0.0
).images[0]
app = gr.Interface(fn=generate_image, inputs="text", outputs="image")
app.launch()

BIN
icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
icon.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

32
install.js Normal file
View File

@@ -0,0 +1,32 @@
module.exports = {
run: [
// Delete this step if your project does not use torch
{
method: "script.start",
params: {
uri: "torch.js",
params: {
venv: "env", // Edit this to customize the venv folder path
// xformers: true // uncomment this line if your project requires xformers
}
}
},
// Edit this step with your custom install commands
{
method: "shell.run",
params: {
venv: "env", // Edit this to customize the venv folder path
message: [
"pip install -r requirements.txt"
],
}
},
{
method: "fs.link",
params: {
venv: "env"
}
}
]
}

87
pinokio.js Normal file
View File

@@ -0,0 +1,87 @@
const path = require('path')
module.exports = {
version: "2.0",
title: "flux-all",
description: "",
icon: "icon.webp",
menu: async (kernel, info) => {
let installed = info.exists("env")
let running = {
install: info.running("install.js"),
start: info.running("start.js"),
update: info.running("update.js"),
reset: info.running("reset.js")
}
if (running.install) {
return [{
default: true,
icon: "fa-solid fa-plug",
text: "Installing",
href: "install.js",
}]
} else if (installed) {
if (running.start) {
let local = info.local("start.js")
if (local && local.url) {
return [{
default: true,
icon: "fa-solid fa-rocket",
text: "Open Web UI",
href: local.url,
}, {
icon: 'fa-solid fa-terminal',
text: "Terminal",
href: "start.js",
}]
} else {
return [{
default: true,
icon: 'fa-solid fa-terminal',
text: "Terminal",
href: "start.js",
}]
}
} else if (running.update) {
return [{
default: true,
icon: 'fa-solid fa-terminal',
text: "Updating",
href: "update.js",
}]
} else if (running.reset) {
return [{
default: true,
icon: 'fa-solid fa-terminal',
text: "Resetting",
href: "reset.js",
}]
} else {
return [{
default: true,
icon: "fa-solid fa-power-off",
text: "Start",
href: "start.js",
}, {
icon: "fa-solid fa-plug",
text: "Update",
href: "update.js",
}, {
icon: "fa-solid fa-plug",
text: "Install",
href: "install.js",
}, {
icon: "fa-regular fa-circle-xmark",
text: "Reset",
href: "reset.js",
}]
}
} else {
return [{
default: true,
icon: "fa-solid fa-plug",
text: "Install",
href: "install.js",
}]
}
}
}

5
requirements.txt Normal file
View File

@@ -0,0 +1,5 @@
transformers
accelerate
diffusers
gradio
devicetorch

8
reset.js Normal file
View File

@@ -0,0 +1,8 @@
module.exports = {
run: [{
method: "fs.rm",
params: {
path: "env"
}
}]
}

36
start.js Normal file
View File

@@ -0,0 +1,36 @@
module.exports = {
daemon: true,
run: [
// Edit this step to customize your app's launch command
{
method: "shell.run",
params: {
venv: "env", // Edit this to customize the venv folder path
env: { }, // Edit this to customize environment variables (see documentation)
message: [
"python app.py", // Edit with your custom commands
],
on: [{
// The regular expression pattern to monitor.
// When this pattern occurs in the shell terminal, the shell will return,
// and the script will go onto the next step.
"event": "/http:\/\/\\S+/",
// "done": true will move to the next step while keeping the shell alive.
// "kill": true will move to the next step after killing the shell.
"done": true
}]
}
},
// This step sets the local variable 'url'.
// This local variable will be used in pinokio.js to display the "Open WebUI" tab when the value is set.
{
method: "local.set",
params: {
// the input.event is the regular expression match object from the previous step
url: "{{input.event[0]}}"
}
},
]
}

74
torch.js Normal file
View File

@@ -0,0 +1,74 @@
module.exports = {
run: [
// windows nvidia
{
"when": "{{platform === 'win32' && gpu === 'nvidia'}}",
"method": "shell.run",
"params": {
"venv": "{{args && args.venv ? args.venv : null}}",
"path": "{{args && args.path ? args.path : '.'}}",
"message": "pip install torch==2.3.1 torchvision==0.18.1 torchaudio==2.3.1 {{args && args.xformers ? 'xformers' : ''}} --index-url https://download.pytorch.org/whl/cu121"
}
},
// windows amd
{
"when": "{{platform === 'win32' && gpu === 'amd'}}",
"method": "shell.run",
"params": {
"venv": "{{args && args.venv ? args.venv : null}}",
"path": "{{args && args.path ? args.path : '.'}}",
"message": "pip install torch-directml torchvision torchaudio"
}
},
// windows cpu
{
"when": "{{platform === 'win32' && (gpu !== 'nvidia' && gpu !== 'amd')}}",
"method": "shell.run",
"params": {
"venv": "{{args && args.venv ? args.venv : null}}",
"path": "{{args && args.path ? args.path : '.'}}",
"message": "pip install torch==2.3.1 torchvision==0.18.1 torchaudio==2.3.1"
}
},
// mac
{
"when": "{{platform === 'darwin'}}",
"method": "shell.run",
"params": {
"venv": "{{args && args.venv ? args.venv : null}}",
"path": "{{args && args.path ? args.path : '.'}}",
"message": "pip install torch==2.3.1 torchvision==0.18.1 torchaudio==2.3.1"
}
},
// linux nvidia
{
"when": "{{platform === 'linux' && gpu === 'nvidia'}}",
"method": "shell.run",
"params": {
"venv": "{{args && args.venv ? args.venv : null}}",
"path": "{{args && args.path ? args.path : '.'}}",
"message": "pip install torch==2.3.1 torchvision==0.18.1 torchaudio==2.3.1 {{args && args.xformers ? 'xformers' : ''}} --index-url https://download.pytorch.org/whl/cu121"
}
},
// linux rocm (amd)
{
"when": "{{platform === 'linux' && gpu === 'amd'}}",
"method": "shell.run",
"params": {
"venv": "{{args && args.venv ? args.venv : null}}",
"path": "{{args && args.path ? args.path : '.'}}",
"message": "pip install torch==2.3.1 torchvision==0.18.1 torchaudio==2.3.1 --index-url https://download.pytorch.org/whl/rocm6.0"
}
},
// linux cpu
{
"when": "{{platform === 'linux' && (gpu !== 'amd' && gpu !=='nvidia')}}",
"method": "shell.run",
"params": {
"venv": "{{args && args.venv ? args.venv : null}}",
"path": "{{args && args.path ? args.path : '.'}}",
"message": "pip install torch==2.3.1 torchvision==0.18.1 torchaudio==2.3.1 --index-url https://download.pytorch.org/whl/cpu"
}
}
]
}

8
update.js Normal file
View File

@@ -0,0 +1,8 @@
module.exports = {
run: [{
method: "shell.run",
params: {
message: "git pull"
}
}]
}