Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/53 support gguf download #5

Merged
merged 5 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
.vscode/
env/
package_res/
python_package_res/
build_resources/
build_envs/
release/
WebUI/external/service/

Expand Down
4 changes: 2 additions & 2 deletions WebUI/build/arc-settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"envType": "arc",
"availableThemes": ["dark"],
"currentTheme": "dark"
"availableThemes": ["dark","lnl","bmg"],
"currentTheme": "bmg"
}
21 changes: 21 additions & 0 deletions WebUI/build/build-config-offline.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,27 @@
"*.bat"
]
},
{
"from": "external/ComfyUI",
"to": "ComfyUI",
"filter": [
"**/*",
"!models/",
"!.vscode/",
"!__pycache__/",
"!test/",
"!db/",
"!cache/",
"!static/",
"!temp/",
"!dist/",
"*.bat"
]
},
{
"from": "external/workflows",
"to": "workflows"
},
{
"from": "external/service/models/stable_diffusion/ESRGAN",
"to": "service/models/stable_diffusion/ESRGAN"
Expand Down
24 changes: 24 additions & 0 deletions WebUI/build/scripts/fetch-python-package-resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
const https = require('https');
const fs = require('fs');
const path = require('path');
const childProcess = require('child_process');


const argv = require('minimist')(process.argv.slice(2));
Expand Down Expand Up @@ -78,12 +79,35 @@ function copyLibuvDllsIfNotPresent() {
}
}

function fetchComfyUIIfNotPresent() {
const comfyUICloneDir = path.join(targetDir, 'ComfyUI')
if (fs.existsSync(comfyUICloneDir)) {
console.log(`omitting fetching of comfyUI as ${comfyUICloneDir} already exists`)
} else {
gitClone("https://github.com/comfyanonymous/ComfyUI.git", comfyUICloneDir)
gitClone("https://github.com/city96/ComfyUI-GGUF.git", path.join(comfyUICloneDir, 'custom_nodes', 'ComfyUI-GGUF'))
}
}


function gitClone(repoURL, targetDir) {
const gitClone = childProcess.spawnSync("git", ["clone", repoURL, targetDir]);
console.log(gitClone.stdout.toString());
console.error(gitClone.stderr.toString());
if (gitClone.status!== 0) {
console.error('Failed to clone repo: ', repoURL);
process.exit(1);
}
console.log('Successfully fetched: ', repoURL);
}


function main() {
prepareTargetPath()
fetchFileIfNotPresent(embeddablePythonUrl)
fetchFileIfNotPresent(getPipScriptUrl)
fetchFileIfNotPresent(sevenZrExeUrl)
fetchComfyUIIfNotPresent()
copyLibuvDllsIfNotPresent()
}

Expand Down
13 changes: 10 additions & 3 deletions WebUI/build/scripts/install-full-python-env.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ const childProcess = require('child_process');
const argv = require('minimist')(process.argv.slice(2));
const envDirArg = argv.env_dir
const platformArg = argv.platform
const comfyUIDIrArg = argv.comfy_ui_dir

if (!envDirArg || !platformArg) {
if (!envDirArg || !platformArg || !comfyUIDIrArg) {
console.error('Usage: node install-full-python-env.js --env_dir=$DIR ---platform=arc|ultra|ultra2\n');
process.exit(1);
}

const envDir = existingFileOrExit(path.resolve(envDirArg));
const comfyUIDIr = existingFileOrExit(path.resolve(comfyUIDIrArg));
const platform = platformArg;

function existingFileOrExit(filePath) {
Expand All @@ -29,7 +31,7 @@ function existingFileOrExit(filePath) {
function installPip(pythonExe, getPipFilePath) {
const runGetPip = childProcess.spawnSync(pythonExe, [getPipFilePath]);
console.log(runGetPip.stdout.toString());
//console.error(runGetPip.stderr.toString());
console.error(runGetPip.stderr.toString());
if (runGetPip.status!== 0) {
console.error('Failed to install requirements');
process.exit(1);
Expand All @@ -56,7 +58,7 @@ function copyToTargetDir(sourceDir, targetDir) {

function prepareTargetDir(targetDir) {
if (fs.existsSync(targetDir)) {
console.log("clearing previous env dir ${targetDir}")
console.log(`clearing previous env dir ${targetDir}`)
fs.rmSync(targetDir, { recursive: true });
}
}
Expand All @@ -72,10 +74,15 @@ function main() {

const platformSpecificRequirementsTxt = existingFileOrExit(path.join(__dirname, '..', '..','..', 'service', `requirements-${platform}.txt`));
const requirementsTxt = existingFileOrExit(path.join(__dirname, '..', '..', '..', 'service', `requirements.txt`));
const comfyUiRequirementsTxt = existingFileOrExit(path.join(comfyUIDIr, `requirements.txt`));
const ggufCostomNoderequirementsTxt = existingFileOrExit(path.join(comfyUIDIr, 'custom_nodes', 'ComfyUI-GGUF', `requirements.txt`));


installPip(pythonExe, getPipFile)
runPipInstall(pythonExe, platformSpecificRequirementsTxt)
runPipInstall(pythonExe, requirementsTxt)
runPipInstall(pythonExe, comfyUiRequirementsTxt)
runPipInstall(pythonExe, ggufCostomNoderequirementsTxt)
}

main();
1 change: 1 addition & 0 deletions WebUI/build/scripts/prepare-python-env.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ function createPythonEnvFromEmbedabblePythonZip(targetDir, pythonEmbedZipFile) {
python311.zip
.
../service
../ComfyUI

# Uncomment to run site.main() automatically
import site
Expand Down
17 changes: 14 additions & 3 deletions WebUI/build/scripts/provide-electron-build-resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,20 @@ function zipPythonEnv(sevenZipExe, pythonEnvDir, targetPath) {
console.log('Offline env has been compressed to:', targetPath);
}

function copyResources(targetDir, ...files) {
function copyFiles(targetDir, ...files) {
for (const file of files) {
console.log(file)
fs.copyFileSync(file, path.join(targetDir, path.basename(file)));
console.log('Copied:', file, 'to:', path.join(targetDir, path.basename(file)));
}
}

function copyDirectories(targetDir, ...dirs) {
for (const dir of dirs) {
fs.cpSync(dir, path.join(targetDir, path.basename(dir)), { recursive: true });
console.log('Copied:', dir, 'to:', path.join(targetDir, path.basename(dir)));
}
}

function clearPreviousZip(zipFilePath) {
if
(fs.existsSync(zipFilePath)) {
Expand All @@ -66,14 +72,19 @@ function clearPreviousZip(zipFilePath) {

function main() {
const sevenZipExe = path.join(buildResourcesDir, '7zr.exe');
const comfyUI = path.join(buildResourcesDir, 'ComfyUI');

clearPreviousZip(path.join(targetDir, `env.7z`));
zipPythonEnv(sevenZipExe, pythenEnvDir, path.join(targetDir, `env.7z`));

symlinkBackendDir(backendDir, path.join(targetDir, 'service'))
copyResources(targetDir,
copyFiles(targetDir,
sevenZipExe
)

copyDirectories(targetDir,
comfyUI
)
}

main()
14 changes: 10 additions & 4 deletions WebUI/external/workflows/fluxQ4.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
"Q4",
"Fast"
],
"requiredModels": [
"unet:city96/FLUX.1-schnell-gguf/flux1-schnell-Q4_K_S.gguf",
"clip:city96/t5-v1_1-xxl-encoder-gguf/t5-v1_1-xxl-encoder-Q3_K_M.gguf",
"clip:comfyanonymous/flux_text_encoders/clip_l.safetensors",
"vae:black-forest-labs/FLUX.1-schnell/ae.safetensors"
],
"requirements": [
"high-vram"
],
Expand Down Expand Up @@ -72,7 +78,7 @@
},
"170": {
"inputs": {
"unet_name": "flux1-schnell-Q4_K_S.gguf"
"unet_name": "city96---FLUX.1-schnell-gguf\\flux1-schnell-Q4_K_S.gguf"
},
"class_type": "UnetLoaderGGUF",
"_meta": {
Expand All @@ -81,7 +87,7 @@
},
"171": {
"inputs": {
"vae_name": "ae.safetensors"
"vae_name": "black-forest-labs/FLUX.1-schnell\\ae.safetensors"
},
"class_type": "VAELoader",
"_meta": {
Expand Down Expand Up @@ -192,8 +198,8 @@
},
"188": {
"inputs": {
"clip_name1": "t5-v1_1-xxl-encoder-Q3_K_M.gguf",
"clip_name2": "clip_l.safetensors",
"clip_name1": "city96---t5-v1_1-xxl-encoder-gguf\\t5-v1_1-xxl-encoder-Q3_K_M.gguf",
"clip_name2": "comfyanonymous---flux_text_encoders\\clip_l.safetensors",
"type": "flux"
},
"class_type": "DualCLIPLoaderGGUF",
Expand Down
14 changes: 10 additions & 4 deletions WebUI/external/workflows/fluxQ8.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
"Q8",
"Fast"
],
"requiredModels": [
"unet:city96/FLUX.1-schnell-gguf/flux1-schnell-Q8_0.gguf",
"clip:city96/t5-v1_1-xxl-encoder-gguf/t5-v1_1-xxl-encoder-Q3_K_M.gguf",
"clip:comfyanonymous/flux_text_encoders/clip_l.safetensors",
"vae:black-forest-labs/FLUX.1-schnell/ae.safetensors"
],
"requirements": [
"high-vram"
],
Expand Down Expand Up @@ -72,7 +78,7 @@
},
"170": {
"inputs": {
"unet_name": "flux1-schnell-Q8_0.gguf"
"unet_name": "city96---FLUX.1-schnell-gguf\\flux1-schnell-Q8_0.gguf"
},
"class_type": "UnetLoaderGGUF",
"_meta": {
Expand All @@ -81,7 +87,7 @@
},
"171": {
"inputs": {
"vae_name": "ae.safetensors"
"vae_name": "black-forest-labs---FLUX.1-schnell\\ae.safetensors"
},
"class_type": "VAELoader",
"_meta": {
Expand Down Expand Up @@ -192,8 +198,8 @@
},
"188": {
"inputs": {
"clip_name1": "t5-v1_1-xxl-encoder-Q3_K_M.gguf",
"clip_name2": "clip_l.safetensors",
"clip_name1": "city96---t5-v1_1-xxl-encoder-gguf\\t5-v1_1-xxl-encoder-Q3_K_M.gguf",
"clip_name2": "comfyanonymous---flux_text_encoders\\clip_l.safetensors",
"type": "flux"
},
"class_type": "DualCLIPLoaderGGUF",
Expand Down
Loading
Loading