Merge branch 'main' of https://github.com/willsmithorg/was-node-suite-comfyui
This commit is contained in:
@@ -0,0 +1,333 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "view-in-github",
|
||||
"colab_type": "text"
|
||||
},
|
||||
"source": [
|
||||
"<a href=\"https://colab.research.google.com/github/WASasquatch/was-node-suite-comfyui/blob/main/ComfyUI_%2B_WAS_Node_Suite_and_ComfyUI_Manager.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "aaaaaaaaaa"
|
||||
},
|
||||
"source": [
|
||||
"# <font color=\"#0497e0\">**Comfy**</font>UI + <font color=\"#4684a3\">**WAS** Node Suite</font> [](https://hits.seeyoufarm.com)\n",
|
||||
"A version of ComfyUI Colab with WAS Node Suite installatoin."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "bbbbbbbbbb",
|
||||
"cellView": "form"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"#@title <font color=\"orange\" size=\"5\">Environment Setup</font>\n",
|
||||
"#@markdown <font color=\"#0497e0\">Download and install ComfyUI + WAS Node Suite. You can run this cell again with the `UPDATE_COMFY_UI` or `UPDATE_WAS_NS` options selected to update.\n",
|
||||
"\n",
|
||||
"from pathlib import Path\n",
|
||||
"import time\n",
|
||||
"\n",
|
||||
"OPTIONS = {}\n",
|
||||
"\n",
|
||||
"#@markdown <font color=\"#48768c\">Store ComfyUI on Google Drive instead of Colab</font>\n",
|
||||
"USE_GOOGLE_DRIVE = False #@param {type:\"boolean\"}\n",
|
||||
"#markdown <font color=\"#48768c\">Update ComfyUI</font>\n",
|
||||
"UPDATE_COMFY_UI = True #@param {type:\"boolean\"}\n",
|
||||
"#@markdown <font color=\"#48768c\">Update WAS Node Suite</font>\n",
|
||||
"UPDATE_WAS_NS = True #@param {type:\"boolean\"}\n",
|
||||
"#@markdown <font color=\"#48768c\">Update Pillow for WAS NS:</font>\n",
|
||||
"UPDATE_PILLOW = False #@param {type:\"boolean\"}\n",
|
||||
"#@markdown <font color=\"#48768c\">ComfyUI Manager:</font>\n",
|
||||
"USE_COMFYUI_MANAGER = True #@param {type:\"boolean\"}\n",
|
||||
"UPDATE_COMFYUI_MANAGER = True #@param {type:\"boolean\"}\n",
|
||||
"\n",
|
||||
"WORKSPACE = '/content/ComfyUI'\n",
|
||||
"OPTIONS['USE_GOOGLE_DRIVE'] = USE_GOOGLE_DRIVE\n",
|
||||
"OPTIONS['UPDATE_COMFY_UI'] = UPDATE_COMFY_UI\n",
|
||||
"\n",
|
||||
"if USE_GOOGLE_DRIVE:\n",
|
||||
" !echo \"Mounting Google Drive...\"\n",
|
||||
" %cd /\n",
|
||||
" from google.colab import drive\n",
|
||||
" drive.mount('/content/drive')\n",
|
||||
" WORKSPACE = \"/content/drive/MyDrive/ComfyUI\"\n",
|
||||
" %cd /content/drive/MyDrive\n",
|
||||
"\n",
|
||||
"![ ! -d $WORKSPACE ] && echo -= Initial setup ComfyUI =- && git clone https://github.com/comfyanonymous/ComfyUI /content/ComfyUI/\n",
|
||||
"%cd $WORKSPACE\n",
|
||||
"\n",
|
||||
"if UPDATE_COMFY_UI:\n",
|
||||
" !echo -= Updating ComfyUI =-\n",
|
||||
" !git pull\n",
|
||||
"\n",
|
||||
"!echo -= Install dependencies =-\n",
|
||||
"!pip install xformers -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cu118\n",
|
||||
"!git clone https://github.com/WASasquatch/was-node-suite-comfyui /content/ComfyUI/custom_nodes/was-node-suite-comfyui\n",
|
||||
"\n",
|
||||
"if USE_COMFYUI_MANAGER:\n",
|
||||
" !git clone https://github.com/ltdrdata/ComfyUI-Manager.git /content/ComfyUI/custom_nodes/ComfyUI-Manager\n",
|
||||
"\n",
|
||||
"if UPDATE_WAS_NS:\n",
|
||||
" %cd /content/ComfyUI/custom_nodes/was-node-suite-comfyui\n",
|
||||
" !git pull\n",
|
||||
" %cd /content/ComfyUI\n",
|
||||
"\n",
|
||||
"if UPDATE_COMFYUI_MANAGER:\n",
|
||||
" %cd /content/ComfyUI/custom_nodes/ComfyUI-Manager\n",
|
||||
" !git pull\n",
|
||||
" %cd /content/ComfyUI\n",
|
||||
"\n",
|
||||
"if UPDATE_PILLOW:\n",
|
||||
" !pip install --upgrade --force-reinstall pillow\n",
|
||||
" print('\\n\\033[91m\\033[1mRestarting runtime for Pillow Update. Run this cell again without `UPDATE_PILLOW` selected!\\033[0m')\n",
|
||||
" time.sleep(5)\n",
|
||||
"\n",
|
||||
" import os\n",
|
||||
" os.kill(os.getpid(), 9)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "cccccccccc"
|
||||
},
|
||||
"source": [
|
||||
"Download some models/checkpoints/vae or custom comfyui nodes (uncomment the commands for the ones you want)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "dddddddddd",
|
||||
"cellView": "form"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"#@title <font color=\"orange\" size=\"5\">Download Models</font>\n",
|
||||
"#@markdown <font color=\"#0497e0\">Download models and other resources to use in ComfyUI. Select your options and run the this cell. Can run multiple times with different options.</font>\n",
|
||||
"\n",
|
||||
"#@markdown ---\n",
|
||||
"\n",
|
||||
"# Checkpoints\n",
|
||||
"\n",
|
||||
"MODEL_OPTION = 'v1-5-pruned-emaonly.ckpt' #@param['None', 'v1-5-pruned-emaonly.ckpt', 'v2-1_512-ema-pruned.safetensors', 'v2-1_768-ema-pruned.safetensors', 'AbyssOrangeMix2_hard.safetensors', 'AOM3A1_orangemixs.safetensors', 'AOM3A3_orangemixs.safetensors', 'wd-1-5-beta2-fp16.safetensors']\n",
|
||||
"VAE_OPTION = 'None' #@param['None', 'vae-ft-mse-840000-ema-pruned.safetensors', 'orangemix.vae.pt', 'kl-f8-anime2.ckpt']\n",
|
||||
"UPSCALE_MODEL_OPTION = 'None' #@param['None', 'RealESRGAN_x2.pth', 'RealESRGAN_x4.pth', '4x-UltraSharp', '4x_RealisticRescaler_100000_G.pth', 'BSRGAN.pth', 'BSRGANx2.pth']\n",
|
||||
"LORA_OPTION = 'None' #@param['None', 'theovercomer8sContrastFix_sd21768.safetensors', 'theovercomer8sContrastFix_sd15.safetensors']\n",
|
||||
"T2I_OPTION = 'None' #@param['None', 't2iadapter_depth_sd14v1.pth', 't2iadapter_seg_sd14v1.pth', 't2iadapter_sketch_sd14v1.pth', 't2iadapter_keypose_sd14v1.pth', 't2iadapter_openpose_sd14v1.pth', 't2iadapter_color_sd14v1.pth', 't2iadapter_canny_sd14v1.pth', '/t2iadapter_style_sd14v1.pth']\n",
|
||||
"CONTROLNET_OPTION = 'None' #@param['None', 'control_depth-fp16.safetensors', 'control_scribble-fp16.safetensors', 'control_openpose-fp16.safetensors']\n",
|
||||
"\n",
|
||||
"#@markdown ---\n",
|
||||
"\n",
|
||||
"#@markdown <font color=\"#0497e0\">**Download and instlal CLIPVision**:</font>\n",
|
||||
"DOWNLOAD_CLIPVISION = False #@param {type:\"boolean\"}\n",
|
||||
"#@markdown <font color=\"#0497e0\">**ControlNet Preprocessor Nodes** by Fannovel16:</font>\n",
|
||||
"INSTALL_CONTROLNET_NODES = False #@param {type:\"boolean\"}\n",
|
||||
"\n",
|
||||
"# SD1.5\n",
|
||||
"if MODEL_OPTION == 'v1-5-pruned-emaonly.ckpt':\n",
|
||||
" !wget -c https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.ckpt -P ./models/checkpoints/\n",
|
||||
"\n",
|
||||
"# SD2\n",
|
||||
"if MODEL_OPTION == 'v2-1_512-ema-pruned.safetensors':\n",
|
||||
" !wget -c https://huggingface.co/stabilityai/stable-diffusion-2-1-base/resolve/main/v2-1_512-ema-pruned.safetensors -P ./models/checkpoints/\n",
|
||||
"if MODEL_OPTION == 'v2-1_768-ema-pruned.safetensors':\n",
|
||||
" !wget -c https://huggingface.co/stabilityai/stable-diffusion-2-1/resolve/main/v2-1_768-ema-pruned.safetensors -P ./models/checkpoints/\n",
|
||||
"\n",
|
||||
"# Some SD1.5 anime style\n",
|
||||
"if MODEL_OPTION == 'AbyssOrangeMix2_hard.safetensors':\n",
|
||||
" !wget -c https://huggingface.co/WarriorMama777/OrangeMixs/resolve/main/Models/AbyssOrangeMix2/AbyssOrangeMix2_hard.safetensors -P ./models/checkpoints/\n",
|
||||
"if MODEL_OPTION == 'AOM3A1_orangemixs.safetensors':\n",
|
||||
" !wget -c https://huggingface.co/WarriorMama777/OrangeMixs/resolve/main/Models/AbyssOrangeMix3/AOM3A1_orangemixs.safetensors -P ./models/checkpoints/\n",
|
||||
"if MODEL_OPTION == 'AOM3A3_orangemixs.safetensors':\n",
|
||||
" !wget -c https://huggingface.co/WarriorMama777/OrangeMixs/resolve/main/Models/AbyssOrangeMix3/AOM3A3_orangemixs.safetensors -P ./models/checkpoints/\n",
|
||||
"if MODEL_OPTION == 'anything-v3-fp16-pruned.safetensors':\n",
|
||||
" !wget -c https://huggingface.co/Linaqruf/anything-v3.0/resolve/main/anything-v3-fp16-pruned.safetensors -P ./models/checkpoints/\n",
|
||||
"\n",
|
||||
"# Waifu Diffusion 1.5 (anime style SD2.x 768-v)\n",
|
||||
"if MODEL_OPTION == 'wd-1-5-beta2-fp16.safetensors':\n",
|
||||
" !wget -c https://huggingface.co/waifu-diffusion/wd-1-5-beta2/resolve/main/checkpoints/wd-1-5-beta2-fp16.safetensors -P ./models/checkpoints/\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"# VAE\n",
|
||||
"if VAE_OPTION == 'vae-ft-mse-840000-ema-pruned.safetensors':\n",
|
||||
" !wget -c https://huggingface.co/stabilityai/sd-vae-ft-mse-original/resolve/main/vae-ft-mse-840000-ema-pruned.safetensors -P ./models/vae/\n",
|
||||
"if VAE_OPTION == 'orangemix.vae.pt':\n",
|
||||
" !wget -c https://huggingface.co/WarriorMama777/OrangeMixs/resolve/main/VAEs/orangemix.vae.pt -P ./models/vae/'\n",
|
||||
"if VAE_OPTION == 'kl-f8-anime2.ckpt':\n",
|
||||
" !wget -c https://huggingface.co/hakurei/waifu-diffusion-v1-4/resolve/main/vae/kl-f8-anime2.ckpt -P ./models/vae/\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"# Loras\n",
|
||||
"if LORA_OPTION == 'theovercomer8sContrastFix_sd21768.safetensors':\n",
|
||||
" !wget -c https://civitai.com/api/download/models/10350 -O ./models/loras/theovercomer8sContrastFix_sd21768.safetensors #theovercomer8sContrastFix SD2.x 768-v\n",
|
||||
"if LORA_OPTION == 'theovercomer8sContrastFix_sd15.safetensors':\n",
|
||||
" !wget -c https://civitai.com/api/download/models/10638 -O ./models/loras/theovercomer8sContrastFix_sd15.safetensors #theovercomer8sContrastFix SD1.x\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"# T2I-Adapter\n",
|
||||
"if T2I_OPTION == 't2iadapter_depth_sd14v1.pth':\n",
|
||||
" !wget -c https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_depth_sd14v1.pth -P ./models/controlnet/\n",
|
||||
"if T2I_OPTION == 't2iadapter_seg_sd14v1.pth':\n",
|
||||
" !wget -c https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_seg_sd14v1.pth -P ./models/controlnet/\n",
|
||||
"if T2I_OPTION == 't2iadapter_sketch_sd14v1.pth':\n",
|
||||
" !wget -c https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_sketch_sd14v1.pth -P ./models/controlnet/\n",
|
||||
"if T2I_OPTION == 't2iadapter_keypose_sd14v1.pth':\n",
|
||||
" !wget -c https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_keypose_sd14v1.pth -P ./models/controlnet/\n",
|
||||
"if T2I_OPTION == 't2iadapter_openpose_sd14v1.pth':\n",
|
||||
" !wget -c https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_openpose_sd14v1.pth -P ./models/controlnet/\n",
|
||||
"if T2I_OPTION == 't2iadapter_color_sd14v1.pth':\n",
|
||||
" !wget -c https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_color_sd14v1.pth -P ./models/controlnet/\n",
|
||||
"if T2I_OPTION == 't2iadapter_canny_sd14v1.pth':\n",
|
||||
" !wget -c https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_canny_sd14v1.pth -P ./models/controlnet/\n",
|
||||
"\n",
|
||||
"# T2I Styles Model\n",
|
||||
"if T2I_OPTION == '/t2iadapter_style_sd14v1.pth':\n",
|
||||
" !wget -c https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_style_sd14v1.pth -P ./models/style_models/\n",
|
||||
"\n",
|
||||
"# CLIPVision model (needed for styles model)\n",
|
||||
"if DOWNLOAD_CLIPVISION:\n",
|
||||
" !wget -c https://huggingface.co/openai/clip-vit-large-patch14/resolve/main/pytorch_model.bin -O ./models/clip_vision/clip_vit14.bin\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"# ControlNet\n",
|
||||
"if CONTROLNET_OPTION == 'control_depth-fp16.safetensors':\n",
|
||||
" !wget -c https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_depth-fp16.safetensors -P ./models/controlnet/\n",
|
||||
"if CONTROLNET_OPTION == 'control_scribble-fp16.safetensors':\n",
|
||||
" !wget -c https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_scribble-fp16.safetensors -P ./models/controlnet/\n",
|
||||
"if CONTROLNET_OPTION == 'control_openpose-fp16.safetensors':\n",
|
||||
" !wget -c https://huggingface.co/webui/ControlNet-modules-safetensors/resolve/main/control_openpose-fp16.safetensors -P ./models/controlnet/\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"# Controlnet Preprocessor nodes by Fannovel16\n",
|
||||
"if INSTALL_CONTROLNET_NODES:\n",
|
||||
" !cd custom_nodes && git clone https://github.com/Fannovel16/comfy_controlnet_preprocessors; cd comfy_controlnet_preprocessors && python install.py\n",
|
||||
"\n",
|
||||
"# ESRGAN upscale model\n",
|
||||
"if UPSCALE_MODEL_OPTION == 'RealESRGAN_x2.pth':\n",
|
||||
" !wget -c https://huggingface.co/sberbank-ai/Real-ESRGAN/resolve/main/RealESRGAN_x2.pth -P ./models/upscale_models/\n",
|
||||
"if UPSCALE_MODEL_OPTION == 'RealESRGAN_x4.pth':\n",
|
||||
" !wget -c https://huggingface.co/sberbank-ai/Real-ESRGAN/resolve/main/RealESRGAN_x4.pth -P ./models/upscale_models/\n",
|
||||
"if UPSCALE_MODEL_OPTION == '4x-UltraSharp':\n",
|
||||
" !wget -c https://huggingface.co/uwg/upscaler/resolve/main/ESRGAN/4x-UltraSharp.pth -P ./models/upscale_models/\n",
|
||||
"if UPSCALE_MODEL_OPTION == '4x_RealisticRescaler_100000_G.pth':\n",
|
||||
" !wget -c https://huggingface.co/uwg/upscaler/resolve/main/ESRGAN/4x_RealisticRescaler_100000_G.pth -P ./models/upscale_models/\n",
|
||||
"if UPSCALE_MODEL_OPTION == 'BSRGAN.pth':\n",
|
||||
" !wget -c https://huggingface.co/uwg/upscaler/resolve/main/ESRGAN/BSRGAN.pth -P ./models/upscale_models/\n",
|
||||
"if UPSCALE_MODEL_OPTION == 'BSRGANx2.pth':\n",
|
||||
" !wget -c https://huggingface.co/uwg/upscaler/resolve/main/ESRGAN/BSRGANx2.pth -P ./models/upscale_models/\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "jjjjjjjjjjjjj",
|
||||
"cellView": "form"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"#@title <font size=\"6\" color=\"orange\">Run ComfyUI</font>\n",
|
||||
"#@markdown <font color=\"0497e0\">Run this cell to start ComfyUI. You'll see a link similar to `your url is: https://slow-yaks-jog-34-72-173-3.loca.lt` (example)</font>\n",
|
||||
"#@markdown <br>*If you have trouble with the red screen of death \"reminder\" not letting you generate, use the iFrame version below.*\n",
|
||||
"!npm install -g localtunnel\n",
|
||||
"\n",
|
||||
"import subprocess\n",
|
||||
"import threading\n",
|
||||
"import time\n",
|
||||
"import socket\n",
|
||||
"def iframe_thread(port):\n",
|
||||
" while True:\n",
|
||||
" time.sleep(0.5)\n",
|
||||
" sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n",
|
||||
" result = sock.connect_ex(('127.0.0.1', port))\n",
|
||||
" if result == 0:\n",
|
||||
" break\n",
|
||||
" sock.close()\n",
|
||||
" print(\"\\nComfyUI finished loading, trying to launch localtunnel (if it gets stuck here localtunnel is having issues)\")\n",
|
||||
" p = subprocess.Popen([\"lt\", \"--port\", \"{}\".format(port)], stdout=subprocess.PIPE)\n",
|
||||
" for line in p.stdout:\n",
|
||||
" print(line.decode(), end='')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"threading.Thread(target=iframe_thread, daemon=True, args=(8188,)).start()\n",
|
||||
"\n",
|
||||
"!python main.py --dont-print-server"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "gggggggggg"
|
||||
},
|
||||
"source": [
|
||||
"### Run ComfyUI with colab iframe ***(use only in case the previous way with localtunnel doesn't work)***\n",
|
||||
"\n",
|
||||
"You should see the ui appear in an iframe. If you get a 403 error, it's your firefox settings or an extension that's messing things up.\n",
|
||||
"\n",
|
||||
"If you want to open it in another window use the link.\n",
|
||||
"\n",
|
||||
"Note that some UI features like live image previews won't work because the colab iframe blocks websockets."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "hhhhhhhhhh",
|
||||
"cellView": "form"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"#@title <font size=\"5\" color=\"orange\">ComfyUI iFrame</font>\n",
|
||||
"import threading\n",
|
||||
"import time\n",
|
||||
"import socket\n",
|
||||
"def iframe_thread(port):\n",
|
||||
" while True:\n",
|
||||
" time.sleep(0.5)\n",
|
||||
" sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n",
|
||||
" result = sock.connect_ex(('127.0.0.1', port))\n",
|
||||
" if result == 0:\n",
|
||||
" break\n",
|
||||
" sock.close()\n",
|
||||
" from google.colab import output\n",
|
||||
" output.serve_kernel_port_as_iframe(port, height=1024)\n",
|
||||
" print(\"to open it in a window you can open this link here:\")\n",
|
||||
" output.serve_kernel_port_as_window(port)\n",
|
||||
"\n",
|
||||
"threading.Thread(target=iframe_thread, daemon=True, args=(8188,)).start()\n",
|
||||
"\n",
|
||||
"!python main.py --dont-print-server"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"accelerator": "GPU",
|
||||
"colab": {
|
||||
"provenance": [],
|
||||
"private_outputs": true,
|
||||
"gpuType": "T4",
|
||||
"include_colab_link": true
|
||||
},
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 0
|
||||
}
|
||||
+20
-18
@@ -46,6 +46,8 @@ import time
|
||||
import torch
|
||||
from tqdm import tqdm
|
||||
|
||||
p310_plus = (sys.version_info >= (3, 10))
|
||||
|
||||
MANIFEST = {
|
||||
"name": "WAS Node Suite",
|
||||
"version": (2,2,2),
|
||||
@@ -5690,19 +5692,18 @@ class WAS_Remove_Rembg:
|
||||
|
||||
# Set bgcolor
|
||||
bgrgba = None
|
||||
match background_color:
|
||||
case "black":
|
||||
bgrgba = [0, 0, 0, 255]
|
||||
case "white":
|
||||
bgrgba = [255, 255, 255, 255]
|
||||
case "magenta":
|
||||
bgrgba = [255, 0, 255, 255]
|
||||
case "chroma green":
|
||||
bgrgba = [0, 177, 64, 255]
|
||||
case "chroma blue":
|
||||
bgrgba = [0, 71, 187, 255]
|
||||
case _:
|
||||
bgrgba = None
|
||||
if background_color == "black":
|
||||
bgrgba = [0, 0, 0, 255]
|
||||
elif background_color == "white":
|
||||
bgrgba = [255, 255, 255, 255]
|
||||
elif background_color == "magenta":
|
||||
bgrgba = [255, 0, 255, 255]
|
||||
elif background_color == "chroma green":
|
||||
bgrgba = [0, 177, 64, 255]
|
||||
elif background_color == "chroma blue":
|
||||
bgrgba = [0, 71, 187, 255]
|
||||
else:
|
||||
bgrgba = None
|
||||
|
||||
if transparency and bgrgba is not None:
|
||||
bgrgba[3] = 0
|
||||
@@ -9510,7 +9511,7 @@ class WAS_Text_String_Truncate:
|
||||
"text": ("STRING", {"forceInput": True}),
|
||||
"truncate_by": (["characters", "words"],),
|
||||
"truncate_from": (["end", "beginning"],),
|
||||
"truncate_to": ("INT", {"default": 10, "min": 1, "max": 99999999, "step": 1}),
|
||||
"truncate_to": ("INT", {"default": 10, "min": -99999999, "max": 99999999, "step": 1}),
|
||||
},
|
||||
"optional": {
|
||||
"text_b": ("STRING", {"forceInput": True}),
|
||||
@@ -9539,14 +9540,15 @@ class WAS_Text_String_Truncate:
|
||||
cstr("Invalid truncate_by. 'truncate_by' must be either 'characters' or 'words'.").error.print()
|
||||
if truncate_by == 'characters':
|
||||
if mode == 'beginning':
|
||||
return string[:max_length]
|
||||
return string[:max_length] if max_length >= 0 else string[max_length:]
|
||||
else:
|
||||
return string[-max_length:]
|
||||
return string[-max_length:] if max_length >= 0 else string[:max_length]
|
||||
words = string.split()
|
||||
if mode == 'beginning':
|
||||
return ' '.join(words[:max_length])
|
||||
return ' '.join(words[:max_length]) if max_length >= 0 else ' '.join(words[max_length:])
|
||||
else:
|
||||
return ' '.join(words[-max_length:])
|
||||
return ' '.join(words[-max_length:]) if max_length >= 0 else ' '.join(words[:max_length])
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user