Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
66493d8cb4 | ||
|
|
b4fd0834e0 | ||
|
|
808b0dedf0 | ||
|
|
c6056b132d | ||
|
|
1ae7cae2df | ||
|
|
ccb6285548 | ||
|
|
092310bc8f | ||
|
|
5c530eb32e | ||
|
|
e35bc23fd1 | ||
|
|
869ac6fd1f | ||
|
|
cb168d64ab | ||
|
|
a89e9e01a6 | ||
|
|
e70b4df9b5 | ||
|
|
af1ef7e441 |
@@ -32,6 +32,31 @@ NOTE: The UltralyticsDetectorProvider node is not part of the ComfyUI-Impact-Pac
|
||||
* With the addition of wildcard support in FaceDetailer, the structure of DETAILER_PIPE-related nodes and Detailer nodes has changed. There may be malfunctions when using the existing workflow.
|
||||
|
||||
|
||||
## How To Install
|
||||
|
||||
### **Recommended**
|
||||
* Install via [ComfyUI-Manager](https://github.com/ltdrdata/ComfyUI-Manager).
|
||||
|
||||
### **Manual**
|
||||
* Navigate to `ComfyUI/custom_nodes` in your terminal (cmd).
|
||||
* Clone the repository under the `custom_nodes` directory using the following command:
|
||||
```
|
||||
git clone https://github.com/ltdrdata/ComfyUI-Impact-Pack comfyui-impact-pack
|
||||
cd comfyui-impact-pack
|
||||
```
|
||||
* Install dependencies in your Python environment.
|
||||
* For Windows Portable, run the following command inside `ComfyUI\custom_nodes\comfyui-impact-pack`:
|
||||
```
|
||||
..\..\..\python_embeded\python.exe -m pip install -r requirements.txt
|
||||
```
|
||||
* If using venv or conda, activate your Python environment first, then run:
|
||||
```
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
### Companion Pack
|
||||
* If you need the `Ultralytics Detector Provider` to use various YOLO detection models, you should also install [ComfyUI-Impact-Subpack](https://github.com/ltdrdata/ComfyUI-Impact-Subpack).
|
||||
|
||||
## Custom Nodes
|
||||
### [Detector nodes](https://github.com/ltdrdata/ComfyUI-extension-tutorials/blob/Main/ComfyUI-Impact-Pack/tutorial/detectors.md)
|
||||
* `SAMLoader` - Loads the SAM model.
|
||||
|
||||
|
After Width: | Height: | Size: 63 KiB |
|
After Width: | Height: | Size: 112 KiB |
@@ -0,0 +1,596 @@
|
||||
{
|
||||
"last_node_id": 5,
|
||||
"last_link_id": 5,
|
||||
"nodes": [
|
||||
{
|
||||
"id": 1,
|
||||
"type": "LoadImage",
|
||||
"pos": [
|
||||
30,
|
||||
210
|
||||
],
|
||||
"size": [
|
||||
390,
|
||||
320
|
||||
],
|
||||
"flags": {},
|
||||
"order": 0,
|
||||
"mode": 0,
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "IMAGE",
|
||||
"type": "IMAGE",
|
||||
"shape": 3,
|
||||
"links": [
|
||||
1
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "MASK",
|
||||
"type": "MASK",
|
||||
"shape": 3,
|
||||
"links": [
|
||||
2
|
||||
]
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"Node name for S&R": "LoadImage"
|
||||
},
|
||||
"widgets_values": [
|
||||
"clipspace/clipspace-mask-609196.2000000011.png [input]",
|
||||
"image"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"type": "PreviewImage",
|
||||
"pos": [
|
||||
1230,
|
||||
210
|
||||
],
|
||||
"size": [
|
||||
210,
|
||||
246
|
||||
],
|
||||
"flags": {},
|
||||
"order": 3,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "images",
|
||||
"type": "IMAGE",
|
||||
"link": 5
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"properties": {
|
||||
"Node name for S&R": "PreviewImage"
|
||||
},
|
||||
"widgets_values": []
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"type": "workflow>Impact::MAKE_BASIC_PIPE",
|
||||
"pos": [
|
||||
20,
|
||||
620
|
||||
],
|
||||
"size": [
|
||||
400,
|
||||
200
|
||||
],
|
||||
"flags": {},
|
||||
"order": 1,
|
||||
"mode": 0,
|
||||
"inputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "basic_pipe",
|
||||
"type": "BASIC_PIPE",
|
||||
"shape": 3,
|
||||
"links": [
|
||||
3
|
||||
]
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"Node name for S&R": "workflow/Impact::MAKE_BASIC_PIPE"
|
||||
},
|
||||
"widgets_values": [
|
||||
"SD1.5/realcartoon3d_v13.safetensors",
|
||||
"(best quality:1.4), fox girl",
|
||||
"(worst quality:1.4), nsfw"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"type": "MaskDetailerPipe",
|
||||
"pos": [
|
||||
530,
|
||||
210
|
||||
],
|
||||
"size": [
|
||||
569.4000244140625,
|
||||
850
|
||||
],
|
||||
"flags": {},
|
||||
"order": 2,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "image",
|
||||
"type": "IMAGE",
|
||||
"link": 1
|
||||
},
|
||||
{
|
||||
"name": "mask",
|
||||
"type": "MASK",
|
||||
"link": 2
|
||||
},
|
||||
{
|
||||
"name": "basic_pipe",
|
||||
"type": "BASIC_PIPE",
|
||||
"link": 3,
|
||||
"slot_index": 2
|
||||
},
|
||||
{
|
||||
"name": "refiner_basic_pipe_opt",
|
||||
"type": "BASIC_PIPE",
|
||||
"shape": 7,
|
||||
"link": null
|
||||
},
|
||||
{
|
||||
"name": "detailer_hook",
|
||||
"type": "DETAILER_HOOK",
|
||||
"shape": 7,
|
||||
"link": null
|
||||
},
|
||||
{
|
||||
"name": "scheduler_func_opt",
|
||||
"type": "SCHEDULER_FUNC",
|
||||
"shape": 7,
|
||||
"link": null
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "image",
|
||||
"type": "IMAGE",
|
||||
"shape": 3,
|
||||
"links": [
|
||||
5
|
||||
],
|
||||
"slot_index": 0
|
||||
},
|
||||
{
|
||||
"name": "cropped_refined",
|
||||
"type": "IMAGE",
|
||||
"shape": 6,
|
||||
"links": null
|
||||
},
|
||||
{
|
||||
"name": "cropped_enhanced_alpha",
|
||||
"type": "IMAGE",
|
||||
"shape": 6,
|
||||
"links": [
|
||||
4
|
||||
],
|
||||
"slot_index": 2
|
||||
},
|
||||
{
|
||||
"name": "basic_pipe",
|
||||
"type": "BASIC_PIPE",
|
||||
"shape": 3,
|
||||
"links": null
|
||||
},
|
||||
{
|
||||
"name": "refiner_basic_pipe_opt",
|
||||
"type": "BASIC_PIPE",
|
||||
"shape": 3,
|
||||
"links": null
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"Node name for S&R": "MaskDetailerPipe"
|
||||
},
|
||||
"widgets_values": [
|
||||
512,
|
||||
true,
|
||||
1024,
|
||||
true,
|
||||
1003,
|
||||
"fixed",
|
||||
20,
|
||||
8,
|
||||
"euler",
|
||||
"normal",
|
||||
0.75,
|
||||
5,
|
||||
3,
|
||||
10,
|
||||
0.2,
|
||||
1,
|
||||
1,
|
||||
false,
|
||||
20,
|
||||
false,
|
||||
false
|
||||
],
|
||||
"color": "#322",
|
||||
"bgcolor": "#533"
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"type": "PreviewImage",
|
||||
"pos": [
|
||||
1230,
|
||||
560
|
||||
],
|
||||
"size": [
|
||||
210,
|
||||
246
|
||||
],
|
||||
"flags": {},
|
||||
"order": 4,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "images",
|
||||
"type": "IMAGE",
|
||||
"link": 4
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"properties": {
|
||||
"Node name for S&R": "PreviewImage"
|
||||
},
|
||||
"widgets_values": []
|
||||
}
|
||||
],
|
||||
"links": [
|
||||
[
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
2,
|
||||
0,
|
||||
"IMAGE"
|
||||
],
|
||||
[
|
||||
2,
|
||||
1,
|
||||
1,
|
||||
2,
|
||||
1,
|
||||
"MASK"
|
||||
],
|
||||
[
|
||||
3,
|
||||
3,
|
||||
0,
|
||||
2,
|
||||
2,
|
||||
"BASIC_PIPE"
|
||||
],
|
||||
[
|
||||
4,
|
||||
2,
|
||||
2,
|
||||
4,
|
||||
0,
|
||||
"IMAGE"
|
||||
],
|
||||
[
|
||||
5,
|
||||
2,
|
||||
0,
|
||||
5,
|
||||
0,
|
||||
"IMAGE"
|
||||
]
|
||||
],
|
||||
"groups": [],
|
||||
"config": {},
|
||||
"extra": {
|
||||
"ds": {
|
||||
"scale": 1,
|
||||
"offset": [
|
||||
80,
|
||||
-110
|
||||
]
|
||||
},
|
||||
"groupNodes": {
|
||||
"Impact::MAKE_BASIC_PIPE": {
|
||||
"author": "Dr.Lt.Data",
|
||||
"category": "",
|
||||
"config": {
|
||||
"1": {
|
||||
"input": {
|
||||
"text": {
|
||||
"name": "Positive prompt"
|
||||
}
|
||||
}
|
||||
},
|
||||
"2": {
|
||||
"input": {
|
||||
"text": {
|
||||
"name": "Negative prompt"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"datetime": 1708272471445,
|
||||
"external": [],
|
||||
"links": [
|
||||
[
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
"CLIP"
|
||||
],
|
||||
[
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
0,
|
||||
1,
|
||||
"CLIP"
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
3,
|
||||
0,
|
||||
1,
|
||||
"MODEL"
|
||||
],
|
||||
[
|
||||
0,
|
||||
1,
|
||||
3,
|
||||
1,
|
||||
1,
|
||||
"CLIP"
|
||||
],
|
||||
[
|
||||
0,
|
||||
2,
|
||||
3,
|
||||
2,
|
||||
1,
|
||||
"VAE"
|
||||
],
|
||||
[
|
||||
1,
|
||||
0,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
"CONDITIONING"
|
||||
],
|
||||
[
|
||||
2,
|
||||
0,
|
||||
3,
|
||||
4,
|
||||
4,
|
||||
"CONDITIONING"
|
||||
]
|
||||
],
|
||||
"nodes": [
|
||||
{
|
||||
"flags": {},
|
||||
"index": 0,
|
||||
"mode": 0,
|
||||
"order": 0,
|
||||
"outputs": [
|
||||
{
|
||||
"links": [],
|
||||
"name": "MODEL",
|
||||
"shape": 3,
|
||||
"slot_index": 0,
|
||||
"type": "MODEL",
|
||||
"localized_name": "MODEL"
|
||||
},
|
||||
{
|
||||
"links": [],
|
||||
"name": "CLIP",
|
||||
"shape": 3,
|
||||
"slot_index": 1,
|
||||
"type": "CLIP",
|
||||
"localized_name": "CLIP"
|
||||
},
|
||||
{
|
||||
"links": [],
|
||||
"name": "VAE",
|
||||
"shape": 3,
|
||||
"slot_index": 2,
|
||||
"type": "VAE",
|
||||
"localized_name": "VAE"
|
||||
}
|
||||
],
|
||||
"pos": [
|
||||
550,
|
||||
360
|
||||
],
|
||||
"properties": {
|
||||
"Node name for S&R": "CheckpointLoaderSimple"
|
||||
},
|
||||
"size": {
|
||||
"0": 315,
|
||||
"1": 98
|
||||
},
|
||||
"type": "CheckpointLoaderSimple",
|
||||
"widgets_values": [
|
||||
"SDXL/sd_xl_base_1.0_0.9vae.safetensors"
|
||||
],
|
||||
"inputs": []
|
||||
},
|
||||
{
|
||||
"flags": {},
|
||||
"index": 1,
|
||||
"inputs": [
|
||||
{
|
||||
"link": null,
|
||||
"name": "clip",
|
||||
"type": "CLIP",
|
||||
"localized_name": "clip"
|
||||
}
|
||||
],
|
||||
"mode": 0,
|
||||
"order": 1,
|
||||
"outputs": [
|
||||
{
|
||||
"links": [],
|
||||
"name": "CONDITIONING",
|
||||
"shape": 3,
|
||||
"slot_index": 0,
|
||||
"type": "CONDITIONING",
|
||||
"localized_name": "CONDITIONING"
|
||||
}
|
||||
],
|
||||
"pos": [
|
||||
940,
|
||||
480
|
||||
],
|
||||
"properties": {
|
||||
"Node name for S&R": "CLIPTextEncode"
|
||||
},
|
||||
"size": {
|
||||
"0": 263,
|
||||
"1": 99
|
||||
},
|
||||
"title": "Positive",
|
||||
"type": "CLIPTextEncode",
|
||||
"widgets_values": [
|
||||
""
|
||||
]
|
||||
},
|
||||
{
|
||||
"flags": {},
|
||||
"index": 2,
|
||||
"inputs": [
|
||||
{
|
||||
"link": null,
|
||||
"name": "clip",
|
||||
"type": "CLIP",
|
||||
"localized_name": "clip"
|
||||
}
|
||||
],
|
||||
"mode": 0,
|
||||
"order": 2,
|
||||
"outputs": [
|
||||
{
|
||||
"links": [],
|
||||
"name": "CONDITIONING",
|
||||
"shape": 3,
|
||||
"slot_index": 0,
|
||||
"type": "CONDITIONING",
|
||||
"localized_name": "CONDITIONING"
|
||||
}
|
||||
],
|
||||
"pos": [
|
||||
940,
|
||||
640
|
||||
],
|
||||
"properties": {
|
||||
"Node name for S&R": "CLIPTextEncode"
|
||||
},
|
||||
"size": {
|
||||
"0": 263,
|
||||
"1": 99
|
||||
},
|
||||
"title": "Negative",
|
||||
"type": "CLIPTextEncode",
|
||||
"widgets_values": [
|
||||
""
|
||||
]
|
||||
},
|
||||
{
|
||||
"flags": {},
|
||||
"index": 3,
|
||||
"inputs": [
|
||||
{
|
||||
"link": null,
|
||||
"name": "model",
|
||||
"type": "MODEL",
|
||||
"localized_name": "model"
|
||||
},
|
||||
{
|
||||
"link": null,
|
||||
"name": "clip",
|
||||
"type": "CLIP",
|
||||
"localized_name": "clip"
|
||||
},
|
||||
{
|
||||
"link": null,
|
||||
"name": "vae",
|
||||
"type": "VAE",
|
||||
"localized_name": "vae"
|
||||
},
|
||||
{
|
||||
"link": null,
|
||||
"name": "positive",
|
||||
"type": "CONDITIONING",
|
||||
"localized_name": "positive"
|
||||
},
|
||||
{
|
||||
"link": null,
|
||||
"name": "negative",
|
||||
"type": "CONDITIONING",
|
||||
"localized_name": "negative"
|
||||
}
|
||||
],
|
||||
"mode": 0,
|
||||
"order": 3,
|
||||
"outputs": [
|
||||
{
|
||||
"links": null,
|
||||
"name": "basic_pipe",
|
||||
"shape": 3,
|
||||
"slot_index": 0,
|
||||
"type": "BASIC_PIPE",
|
||||
"localized_name": "basic_pipe"
|
||||
}
|
||||
],
|
||||
"pos": [
|
||||
1320,
|
||||
360
|
||||
],
|
||||
"properties": {
|
||||
"Node name for S&R": "ToBasicPipe"
|
||||
},
|
||||
"size": {
|
||||
"0": 241.79998779296875,
|
||||
"1": 106
|
||||
},
|
||||
"type": "ToBasicPipe"
|
||||
}
|
||||
],
|
||||
"packname": "Impact",
|
||||
"version": "1.0"
|
||||
}
|
||||
},
|
||||
"controller_panel": {
|
||||
"controllers": {},
|
||||
"hidden": true,
|
||||
"highlight": true,
|
||||
"version": 2,
|
||||
"default_order": []
|
||||
},
|
||||
"node_versions": {
|
||||
"comfy-core": "0.3.14",
|
||||
"comfyui-impact-pack": "1ae7cae2df8cca06027edfa3a24512671239d6c4"
|
||||
},
|
||||
"ue_links": [],
|
||||
"VHS_latentpreview": false,
|
||||
"VHS_latentpreviewrate": 0,
|
||||
"VHS_MetadataImage": true,
|
||||
"VHS_KeepIntermediate": true
|
||||
},
|
||||
"version": 0.4
|
||||
}
|
||||
|
After Width: | Height: | Size: 42 KiB |
|
After Width: | Height: | Size: 106 KiB |
|
After Width: | Height: | Size: 67 KiB |
|
After Width: | Height: | Size: 128 KiB |
|
After Width: | Height: | Size: 526 KiB |
@@ -1,35 +0,0 @@
|
||||
import { ComfyApp, app } from "../../scripts/app.js";
|
||||
|
||||
let conflict_check = undefined;
|
||||
|
||||
app.registerExtension({
|
||||
name: "Comfy.impact.comboBoolMigration",
|
||||
|
||||
nodeCreated(node, app) {
|
||||
for(let i in node.widgets) {
|
||||
let widget = node.widgets[i];
|
||||
|
||||
if(conflict_check == undefined) {
|
||||
conflict_check = !!app.extensions.find((ext) => ext.name === "Comfy.comboBoolMigration");
|
||||
}
|
||||
|
||||
if(conflict_check)
|
||||
return;
|
||||
|
||||
if(widget.type == "toggle") {
|
||||
let value = widget.value;
|
||||
|
||||
var v = Object.getOwnPropertyDescriptor(widget, 'value');
|
||||
if(!v) {
|
||||
Object.defineProperty(widget, "value", {
|
||||
set: (value) => {
|
||||
delete widget.value;
|
||||
widget.value = value == true || value == widget.options.on;
|
||||
},
|
||||
get: () => { return value; }
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -93,7 +93,7 @@ const input_dirty = {};
|
||||
const output_tracking = {};
|
||||
|
||||
function progressExecuteHandler(event) {
|
||||
if(event.detail.output.aux){
|
||||
if(event.detail?.output?.aux){
|
||||
const id = event.detail.node;
|
||||
if(input_tracking.hasOwnProperty(id)) {
|
||||
if(input_tracking.hasOwnProperty(id) && input_tracking[id][0] != event.detail.output.aux[0]) {
|
||||
@@ -223,29 +223,29 @@ api.addEventListener("executed", progressExecuteHandler);
|
||||
app.registerExtension({
|
||||
name: "Comfy.Impack",
|
||||
|
||||
commands: [
|
||||
{
|
||||
id: 'refresh-impact-wildcard',
|
||||
label: 'Impact: Refresh Wildcard',
|
||||
function: async () => {
|
||||
await api.fetchApi('/impact/wildcards/refresh');
|
||||
await load_wildcards();
|
||||
app.extensionManager.toast.add({
|
||||
severity: 'info',
|
||||
summary: 'Refreshed!',
|
||||
detail: 'Impact Wildcard List is refreshed!!',
|
||||
life: 3000
|
||||
});
|
||||
}
|
||||
}
|
||||
],
|
||||
commands: [
|
||||
{
|
||||
id: 'refresh-impact-wildcard',
|
||||
label: 'Impact: Refresh Wildcard',
|
||||
function: async () => {
|
||||
await api.fetchApi('/impact/wildcards/refresh');
|
||||
await load_wildcards();
|
||||
app.extensionManager.toast.add({
|
||||
severity: 'info',
|
||||
summary: 'Refreshed!',
|
||||
detail: 'Impact Wildcard List is refreshed!!',
|
||||
life: 3000
|
||||
});
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
menuCommands: [
|
||||
{
|
||||
path: ['Edit'],
|
||||
commands: ['refresh-impact-wildcard']
|
||||
}
|
||||
],
|
||||
menuCommands: [
|
||||
{
|
||||
path: ['Edit'],
|
||||
commands: ['refresh-impact-wildcard']
|
||||
}
|
||||
],
|
||||
|
||||
loadedGraphNode(node, app) {
|
||||
if (node.comfyClass == "MaskPainter") {
|
||||
@@ -273,7 +273,7 @@ app.registerExtension({
|
||||
}
|
||||
else {
|
||||
const node = app.graph.getNodeById(link_info.origin_id);
|
||||
slot_type = node.outputs[link_info.origin_slot].type;
|
||||
slot_type = node.outputs[link_info.origin_slot]?.type;
|
||||
}
|
||||
|
||||
this.inputs[0].type = slot_type;
|
||||
@@ -617,12 +617,14 @@ app.registerExtension({
|
||||
|
||||
if(node.comfyClass == "ImpactSEGSLabelFilter" || node.comfyClass == "SEGSLabelFilterDetailerHookProvider") {
|
||||
node.widgets[0].callback = (value, canvas, node, pos, e) => {
|
||||
if(node.widgets[1].value.trim() != "" && !node.widgets[1].value.trim().endsWith(","))
|
||||
node.widgets[1].value += ", "
|
||||
if(node) {
|
||||
if(node.widgets[1].value.trim() != "" && !node.widgets[1].value.trim().endsWith(","))
|
||||
node.widgets[1].value += ", "
|
||||
|
||||
node.widgets[1].value += value;
|
||||
if(node.widgets_values)
|
||||
node.widgets_values[1] = node.widgets[1].value;
|
||||
node.widgets[1].value += value;
|
||||
if(node.widgets_values)
|
||||
node.widgets_values[1] = node.widgets[1].value;
|
||||
}
|
||||
}
|
||||
|
||||
Object.defineProperty(node.widgets[0], "value", {
|
||||
@@ -696,18 +698,20 @@ app.registerExtension({
|
||||
break;
|
||||
}
|
||||
|
||||
node.widgets[combo_id+1].callback = (value, canvas, node, pos, e) => {
|
||||
if(node.widgets[tbox_id].value != '')
|
||||
node.widgets[tbox_id].value += ', '
|
||||
node.widgets[combo_id+1].callback = (value, canvas, node, pos, e) => {
|
||||
if(node) {
|
||||
if(node.widgets[tbox_id].value != '')
|
||||
node.widgets[tbox_id].value += ', '
|
||||
|
||||
node.widgets[tbox_id].value += node._wildcard_value;
|
||||
}
|
||||
node.widgets[tbox_id].value += node._wildcard_value;
|
||||
}
|
||||
}
|
||||
|
||||
Object.defineProperty(node.widgets[combo_id+1], "value", {
|
||||
set: (value) => {
|
||||
if (value !== "Select the Wildcard to add to the text")
|
||||
node._wildcard_value = value;
|
||||
},
|
||||
if (value !== "Select the Wildcard to add to the text")
|
||||
node._wildcard_value = value;
|
||||
},
|
||||
get: () => { return "Select the Wildcard to add to the text"; }
|
||||
});
|
||||
|
||||
@@ -720,14 +724,16 @@ app.registerExtension({
|
||||
|
||||
if(has_lora) {
|
||||
node.widgets[combo_id].callback = (value, canvas, node, pos, e) => {
|
||||
let lora_name = node._value;
|
||||
if(lora_name.endsWith('.safetensors')) {
|
||||
lora_name = lora_name.slice(0, -12);
|
||||
}
|
||||
if(node) {
|
||||
let lora_name = node._value;
|
||||
if(lora_name.endsWith('.safetensors')) {
|
||||
lora_name = lora_name.slice(0, -12);
|
||||
}
|
||||
|
||||
node.widgets[tbox_id].value += `<lora:${lora_name}>`;
|
||||
if(node.widgets_values) {
|
||||
node.widgets_values[tbox_id] = node.widgets[tbox_id].value;
|
||||
node.widgets[tbox_id].value += `<lora:${lora_name}>`;
|
||||
if(node.widgets_values) {
|
||||
node.widgets_values[tbox_id] = node.widgets[tbox_id].value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -759,14 +765,20 @@ app.registerExtension({
|
||||
// mode combo
|
||||
Object.defineProperty(mode_widget, "value", {
|
||||
set: (value) => {
|
||||
node._mode_value = value == true || value == "Populate";
|
||||
populated_text_widget.inputEl.disabled = value == true || value == "Populate";
|
||||
if(value == true)
|
||||
node._mode_value = "populate";
|
||||
else if(value == false)
|
||||
node._mode_value = "fixed";
|
||||
else
|
||||
node._mode_value = value; // combo value
|
||||
|
||||
populated_text_widget.inputEl.disabled = node._mode_value == 'populate';
|
||||
},
|
||||
get: () => {
|
||||
if(node._mode_value != undefined)
|
||||
return node._mode_value;
|
||||
else
|
||||
return true;
|
||||
return 'populate';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -45,6 +45,8 @@ class SEGSDetailerForAnimateDiff:
|
||||
|
||||
CATEGORY = "ImpactPack/Detailer"
|
||||
|
||||
DESCRIPTION = "This node enhances details by inpainting each region within the detected area bundle (SEGS) after enlarging them based on the guide size.\nThis node is applied specifically to SEGS rather than the entire image. To apply it to the entire image, use the 'SEGS Paste' node.\nAs a specialized detailer node for improving video details, such as in AnimateDiff, this node can handle cases where the masks contained in SEGS serve as batch masks spanning multiple frames."
|
||||
|
||||
@staticmethod
|
||||
def do_detail(image_frames, segs, guide_size, guide_size_for, max_size, seed, steps, cfg, sampler_name, scheduler,
|
||||
denoise, basic_pipe, refiner_ratio=None, refiner_basic_pipe_opt=None, noise_mask_feather=0, scheduler_func_opt=None):
|
||||
@@ -166,6 +168,8 @@ class DetailerForEachPipeForAnimateDiff:
|
||||
|
||||
CATEGORY = "ImpactPack/Detailer"
|
||||
|
||||
DESCRIPTION = "This node enhances details by inpainting each region within the detected area bundle (SEGS) after enlarging them based on the guide size.\nThis node is a specialized detailer node for enhancing video details, such as in AnimateDiff. It can handle cases where the masks contained in SEGS serve as batch masks spanning multiple frames."
|
||||
|
||||
@staticmethod
|
||||
def doit(image_frames, segs, guide_size, guide_size_for, max_size, seed, steps, cfg, sampler_name, scheduler,
|
||||
denoise, feather, basic_pipe, refiner_ratio=None, detailer_hook=None, refiner_basic_pipe_opt=None,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import configparser
|
||||
import os
|
||||
|
||||
version_code = [8, 4, 1]
|
||||
version_code = [8, 8, 2]
|
||||
version = f"V{version_code[0]}.{version_code[1]}" + (f'.{version_code[2]}' if len(version_code) > 2 else '')
|
||||
|
||||
dependency_version = 24
|
||||
|
||||
@@ -228,6 +228,8 @@ class DetailerForEach:
|
||||
|
||||
CATEGORY = "ImpactPack/Detailer"
|
||||
|
||||
DESCRIPTION = "It enhances details by inpainting each region within the detected area bundle (SEGS) after enlarging them based on the guide size."
|
||||
|
||||
@staticmethod
|
||||
def get_core_module():
|
||||
return core
|
||||
@@ -442,6 +444,8 @@ class DetailerForEachPipe:
|
||||
|
||||
CATEGORY = "ImpactPack/Detailer"
|
||||
|
||||
DESCRIPTION = DetailerForEach.DESCRIPTION
|
||||
|
||||
def doit(self, image, segs, guide_size, guide_size_for, max_size, seed, steps, cfg, sampler_name, scheduler,
|
||||
denoise, feather, noise_mask, force_inpaint, basic_pipe, wildcard,
|
||||
refiner_ratio=None, detailer_hook=None, refiner_basic_pipe_opt=None,
|
||||
@@ -533,6 +537,8 @@ class FaceDetailer:
|
||||
|
||||
CATEGORY = "ImpactPack/Simple"
|
||||
|
||||
DESCRIPTION = "This node enhances details by automatically detecting specific objects in the input image using detection models (bbox, segm, sam) and regenerating the image by enlarging the detected area based on the guide size.\nAlthough this node is specialized to simplify the commonly used facial detail enhancement workflow, it can also be used for various automatic inpainting purposes depending on the detection model."
|
||||
|
||||
@staticmethod
|
||||
def enhance_face(image, model, clip, vae, guide_size, guide_size_for_bbox, max_size, seed, steps, cfg, sampler_name, scheduler,
|
||||
positive, negative, denoise, feather, noise_mask, force_inpaint,
|
||||
@@ -1407,6 +1413,8 @@ class FaceDetailerPipe:
|
||||
|
||||
CATEGORY = "ImpactPack/Simple"
|
||||
|
||||
DESCRIPTION = FaceDetailer.DESCRIPTION
|
||||
|
||||
def doit(self, image, detailer_pipe, guide_size, guide_size_for, max_size, seed, steps, cfg, sampler_name, scheduler,
|
||||
denoise, feather, noise_mask, force_inpaint, bbox_threshold, bbox_dilation, bbox_crop_factor,
|
||||
sam_detection_hint, sam_dilation, sam_threshold, sam_bbox_expansion,
|
||||
@@ -1502,6 +1510,8 @@ class MaskDetailerPipe:
|
||||
|
||||
CATEGORY = "ImpactPack/Detailer"
|
||||
|
||||
DESCRIPTION = ""
|
||||
|
||||
def doit(self, image, mask, basic_pipe, guide_size, guide_size_for, max_size, mask_mode,
|
||||
seed, steps, cfg, sampler_name, scheduler, denoise,
|
||||
feather, crop_factor, drop_size, refiner_ratio, batch_size, cycle=1,
|
||||
@@ -1607,6 +1617,8 @@ class DetailerForEachTestPipe(DetailerForEachPipe):
|
||||
|
||||
CATEGORY = "ImpactPack/Detailer"
|
||||
|
||||
DESCRIPTION = DetailerForEach.DESCRIPTION
|
||||
|
||||
def doit(self, image, segs, guide_size, guide_size_for, max_size, seed, steps, cfg, sampler_name, scheduler,
|
||||
denoise, feather, noise_mask, force_inpaint, basic_pipe, wildcard, cycle=1,
|
||||
refiner_ratio=None, detailer_hook=None, refiner_basic_pipe_opt=None, inpaint_model=False, noise_mask_feather=0,
|
||||
@@ -2343,7 +2355,11 @@ class ImpactWildcardProcessor:
|
||||
return {"required": {
|
||||
"wildcard_text": ("STRING", {"multiline": True, "dynamicPrompts": False, "tooltip": "Enter a prompt using wildcard syntax."}),
|
||||
"populated_text": ("STRING", {"multiline": True, "dynamicPrompts": False, "tooltip": "The actual value passed during the execution of 'ImpactWildcardProcessor' is what is shown here. The behavior varies slightly depending on the mode. Wildcard syntax can also be used in 'populated_text'."}),
|
||||
"mode": ("BOOLEAN", {"default": True, "label_on": "Populate", "label_off": "Fixed", "tooltip": "Populate: Before running the workflow, it overwrites the existing value of 'populated_text' with the prompt processed from 'wildcard_text'. In this mode, 'populated_text' cannot be edited.\nFixed: Ignores wildcard_text and keeps 'populated_text' as is. You can edit 'populated_text' in this mode."}),
|
||||
"mode": (["populate", "fixed", "reproduce"], {"default": "populate", "tooltip":
|
||||
"populate: Before running the workflow, it overwrites the existing value of 'populated_text' with the prompt processed from 'wildcard_text'. In this mode, 'populated_text' cannot be edited.\n"
|
||||
"fixed: Ignores wildcard_text and keeps 'populated_text' as is. You can edit 'populated_text' in this mode.\n"
|
||||
"reproduce: This mode operates as 'fixed' mode only once for reproduction, and then it switches to 'populate' mode."
|
||||
}),
|
||||
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff, "tooltip": "Determines the random seed to be used for wildcard processing."}),
|
||||
"Select to add Wildcard": (["Select the Wildcard to add to the text"],),
|
||||
},
|
||||
@@ -2352,9 +2368,10 @@ class ImpactWildcardProcessor:
|
||||
CATEGORY = "ImpactPack/Prompt"
|
||||
|
||||
DESCRIPTION = ("The 'ImpactWildcardProcessor' processes text prompts written in wildcard syntax and outputs the processed text prompt.\n\n"
|
||||
"TIP: Before the workflow is executed, the processing result of 'wildcard_text' is displayed in 'populated_text', and the populated text is saved along with the workflow. If you want to use a seed converted as input, write the prompt directly in 'populated_text' instead of 'wildcard_text', and set the mode to 'Fixed'.")
|
||||
"TIP: Before the workflow is executed, the processing result of 'wildcard_text' is displayed in 'populated_text', and the populated text is saved along with the workflow. If you want to use a seed converted as input, write the prompt directly in 'populated_text' instead of 'wildcard_text', and set the mode to 'fixed'.")
|
||||
|
||||
RETURN_TYPES = ("STRING", )
|
||||
RETURN_NAMES = ("processed text",)
|
||||
FUNCTION = "doit"
|
||||
|
||||
@staticmethod
|
||||
@@ -2374,8 +2391,10 @@ class ImpactWildcardEncode:
|
||||
"clip": ("CLIP",),
|
||||
"wildcard_text": ("STRING", {"multiline": True, "dynamicPrompts": False, "tooltip": "Enter a prompt using wildcard syntax."}),
|
||||
"populated_text": ("STRING", {"multiline": True, "dynamicPrompts": False, "tooltip": "The actual value passed during the execution of 'ImpactWildcardEncode' is what is shown here. The behavior varies slightly depending on the mode. Wildcard syntax can also be used in 'populated_text'."}),
|
||||
"mode": ("BOOLEAN", {"default": True, "label_on": "Populate", "label_off": "Fixed", "tooltip": "Populate: Before running the workflow, it overwrites the existing value of 'populated_text' with the prompt processed from 'wildcard_text'. In this mode, 'populated_text' cannot be edited.\n"
|
||||
"Fixed: Ignores wildcard_text and keeps 'populated_text' as is. You can edit 'populated_text' in this mode."}),
|
||||
"mode": (["populate", "fixed", "reproduce"], {"tooltip":
|
||||
"populate: Before running the workflow, it overwrites the existing value of 'populated_text' with the prompt processed from 'wildcard_text'. In this mode, 'populated_text' cannot be edited.\n"
|
||||
"fixed: Ignores wildcard_text and keeps 'populated_text' as is. You can edit 'populated_text' in this mode\n."
|
||||
"reproduce: This mode operates as 'fixed' mode only once for reproduction, and then it switches to 'populate' mode."}),
|
||||
"Select to add LoRA": (["Select the LoRA to add to the text"] + folder_paths.get_filename_list("loras"), ),
|
||||
"Select to add Wildcard": (["Select the Wildcard to add to the text"], ),
|
||||
"seed": ("INT", {"default": 0, "min": 0, "max": 0xffffffffffffffff, "tooltip": "Determines the random seed to be used for wildcard processing."}),
|
||||
@@ -2385,7 +2404,7 @@ class ImpactWildcardEncode:
|
||||
CATEGORY = "ImpactPack/Prompt"
|
||||
|
||||
DESCRIPTION = ("The 'ImpactWildcardEncode' node processes text prompts written in wildcard syntax and outputs them as conditioning. It also supports LoRA syntax, with the applied LoRA reflected in the model's output.\n\n"
|
||||
"TIP1: Before the workflow is executed, the processing result of 'wildcard_text' is displayed in 'populated_text', and the populated text is saved along with the workflow. If you want to use a seed converted as input, write the prompt directly in 'populated_text' instead of 'wildcard_text', and set the mode to 'Fixed'.\n"
|
||||
"TIP1: Before the workflow is executed, the processing result of 'wildcard_text' is displayed in 'populated_text', and the populated text is saved along with the workflow. If you want to use a seed converted as input, write the prompt directly in 'populated_text' instead of 'wildcard_text', and set the mode to 'fixed'.\n"
|
||||
"TIP2: If the 'Inspire Pack' is installed, LBW(LoRA Block Weight) syntax can also be applied.")
|
||||
|
||||
RETURN_TYPES = ("MODEL", "CLIP", "CONDITIONING", "STRING")
|
||||
|
||||
@@ -46,65 +46,27 @@ def get_noise_sampler(x, cpu, total_sigmas, **kwargs):
|
||||
|
||||
|
||||
def ksampler(sampler_name, total_sigmas, extra_options={}, inpaint_options={}):
|
||||
if sampler_name == "dpmpp_sde":
|
||||
def sample_dpmpp_sde(model, x, sigmas, **kwargs):
|
||||
noise_sampler = get_noise_sampler(x, True, total_sigmas, **kwargs)
|
||||
if noise_sampler is not None:
|
||||
kwargs['noise_sampler'] = noise_sampler
|
||||
if sampler_name in ["dpmpp_sde", "dpmpp_sde_gpu", "dpmpp_2m_sde", "dpmpp_2m_sde_gpu", "dpmpp_3m_sde", "dpmpp_3m_sde_gpu"]:
|
||||
if sampler_name == "dpmpp_sde":
|
||||
orig_sampler_function = k_diffusion_sampling.sample_dpmpp_sde
|
||||
elif sampler_name == "dpmpp_sde_gpu":
|
||||
orig_sampler_function = k_diffusion_sampling.sample_dpmpp_sde_gpu
|
||||
elif sampler_name == "dpmpp_2m_sde":
|
||||
orig_sampler_function = k_diffusion_sampling.sample_dpmpp_2m_sde
|
||||
elif sampler_name == "dpmpp_2m_sde_gpu":
|
||||
orig_sampler_function = k_diffusion_sampling.sample_dpmpp_2m_sde_gpu
|
||||
elif sampler_name == "dpmpp_3m_sde":
|
||||
orig_sampler_function = k_diffusion_sampling.sample_dpmpp_3m_sde
|
||||
elif sampler_name == "dpmpp_3m_sde_gpu":
|
||||
orig_sampler_function = k_diffusion_sampling.sample_dpmpp_3m_sde_gpu
|
||||
|
||||
return k_diffusion_sampling.sample_dpmpp_sde(model, x, sigmas, **kwargs)
|
||||
def sampler_function_wrapper(model, x, sigmas, **kwargs):
|
||||
if 'noise_sampler' not in kwargs:
|
||||
kwargs['noise_sampler'] = get_noise_sampler(x, 'gpu' not in sampler_name, total_sigmas, **kwargs)
|
||||
|
||||
sampler_function = sample_dpmpp_sde
|
||||
return orig_sampler_function(model, x, sigmas, **kwargs)
|
||||
|
||||
elif sampler_name == "dpmpp_sde_gpu":
|
||||
def sample_dpmpp_sde(model, x, sigmas, **kwargs):
|
||||
noise_sampler = get_noise_sampler(x, False, total_sigmas, **kwargs)
|
||||
if noise_sampler is not None:
|
||||
kwargs['noise_sampler'] = noise_sampler
|
||||
|
||||
return k_diffusion_sampling.sample_dpmpp_sde_gpu(model, x, sigmas, **kwargs)
|
||||
|
||||
sampler_function = sample_dpmpp_sde
|
||||
|
||||
elif sampler_name == "dpmpp_2m_sde":
|
||||
def sample_dpmpp_sde(model, x, sigmas, **kwargs):
|
||||
noise_sampler = get_noise_sampler(x, True, total_sigmas, **kwargs)
|
||||
if noise_sampler is not None:
|
||||
kwargs['noise_sampler'] = noise_sampler
|
||||
|
||||
return k_diffusion_sampling.sample_dpmpp_2m_sde(model, x, sigmas, **kwargs)
|
||||
|
||||
sampler_function = sample_dpmpp_sde
|
||||
|
||||
elif sampler_name == "dpmpp_2m_sde_gpu":
|
||||
def sample_dpmpp_sde(model, x, sigmas, **kwargs):
|
||||
noise_sampler = get_noise_sampler(x, False, total_sigmas, **kwargs)
|
||||
if noise_sampler is not None:
|
||||
kwargs['noise_sampler'] = noise_sampler
|
||||
|
||||
return k_diffusion_sampling.sample_dpmpp_2m_sde_gpu(model, x, sigmas, **kwargs)
|
||||
|
||||
sampler_function = sample_dpmpp_sde
|
||||
|
||||
elif sampler_name == "dpmpp_3m_sde":
|
||||
def sample_dpmpp_sde(model, x, sigmas, **kwargs):
|
||||
noise_sampler = get_noise_sampler(x, True, total_sigmas, **kwargs)
|
||||
if noise_sampler is not None:
|
||||
kwargs['noise_sampler'] = noise_sampler
|
||||
|
||||
return k_diffusion_sampling.sample_dpmpp_3m_sde(model, x, sigmas, **kwargs)
|
||||
|
||||
sampler_function = sample_dpmpp_sde
|
||||
|
||||
elif sampler_name == "dpmpp_3m_sde_gpu":
|
||||
def sample_dpmpp_sde(model, x, sigmas, **kwargs):
|
||||
noise_sampler = get_noise_sampler(x, False, total_sigmas, **kwargs)
|
||||
if noise_sampler is not None:
|
||||
kwargs['noise_sampler'] = noise_sampler
|
||||
|
||||
return k_diffusion_sampling.sample_dpmpp_3m_sde_gpu(model, x, sigmas, **kwargs)
|
||||
|
||||
sampler_function = sample_dpmpp_sde
|
||||
sampler_function = sampler_function_wrapper
|
||||
|
||||
else:
|
||||
return comfy.samplers.sampler_object(sampler_name)
|
||||
|
||||
@@ -78,9 +78,13 @@ async def sam_prepare(request):
|
||||
if data['sam_model_name'] == 'auto':
|
||||
model_name = impact.config.get_config()['sam_editor_model']
|
||||
|
||||
model_name = os.path.join(impact_pack.model_path, "sams", model_name)
|
||||
model_path = folder_paths.get_full_path("sams", model_name)
|
||||
|
||||
logging.info(f"[Impact Pack] Loading SAM model '{impact_pack.model_path}'")
|
||||
if model_path is None:
|
||||
logging.error(f"[Impact Pack] The '{model_name}' model file cannot be found in any sams model path.")
|
||||
return web.Response(status=400)
|
||||
|
||||
logging.info(f"[Impact Pack] Loading SAM model '{model_path}'")
|
||||
|
||||
filename, image_dir = folder_paths.annotated_filepath(data["filename"])
|
||||
|
||||
@@ -93,7 +97,7 @@ async def sam_prepare(request):
|
||||
if image_dir is None:
|
||||
return web.Response(status=400)
|
||||
|
||||
thread = threading.Thread(target=async_prepare_sam, args=(image_dir, model_name, filename,))
|
||||
thread = threading.Thread(target=async_prepare_sam, args=(image_dir, model_path, filename,))
|
||||
thread.start()
|
||||
|
||||
logging.info("[Impact Pack] SAM model loaded. ")
|
||||
@@ -478,7 +482,17 @@ def onprompt_populate_wildcards(json_data):
|
||||
for k, v in prompt.items():
|
||||
if 'class_type' in v and (v['class_type'] == 'ImpactWildcardEncode' or v['class_type'] == 'ImpactWildcardProcessor'):
|
||||
inputs = v['inputs']
|
||||
if inputs['mode'] and isinstance(inputs['populated_text'], str):
|
||||
|
||||
# legacy adapter
|
||||
if isinstance(inputs['mode'], bool):
|
||||
if inputs['mode']:
|
||||
new_mode = 'populate'
|
||||
else:
|
||||
new_mode = 'fixed'
|
||||
|
||||
inputs['mode'] = new_mode
|
||||
|
||||
if inputs['mode'] == 'populate' and isinstance(inputs['populated_text'], str):
|
||||
if isinstance(inputs['seed'], list):
|
||||
try:
|
||||
input_node = prompt[inputs['seed'][0]]
|
||||
@@ -499,17 +513,22 @@ def onprompt_populate_wildcards(json_data):
|
||||
input_seed = int(inputs['seed'])
|
||||
|
||||
inputs['populated_text'] = wildcards.process(inputs['wildcard_text'], input_seed)
|
||||
inputs['mode'] = False
|
||||
inputs['mode'] = 'reproduce'
|
||||
|
||||
PromptServer.instance.send_sync("impact-node-feedback", {"node_id": k, "widget_name": "populated_text", "type": "STRING", "value": inputs['populated_text']})
|
||||
updated_widget_values[k] = inputs['populated_text']
|
||||
|
||||
if inputs['mode'] == 'reproduce':
|
||||
PromptServer.instance.send_sync("impact-node-feedback", {"node_id": k, "widget_name": "mode", "type": "STRING", "value": 'populate'})
|
||||
|
||||
|
||||
|
||||
if 'extra_data' in json_data and 'extra_pnginfo' in json_data['extra_data']:
|
||||
for node in json_data['extra_data']['extra_pnginfo']['workflow']['nodes']:
|
||||
key = str(node['id'])
|
||||
if key in updated_widget_values:
|
||||
node['widgets_values'][1] = updated_widget_values[key]
|
||||
node['widgets_values'][2] = False
|
||||
node['widgets_values'][2] = 'reproduce'
|
||||
|
||||
|
||||
def onprompt_for_remote(json_data):
|
||||
|
||||
@@ -60,6 +60,8 @@ class SEGSDetailer:
|
||||
|
||||
CATEGORY = "ImpactPack/Detailer"
|
||||
|
||||
DESCRIPTION = "This node enhances details by inpainting each region within the detected area bundle (SEGS) after enlarging them based on the guide size.\nThis node is applied specifically to SEGS rather than the entire image. To apply it to the entire image, use the 'SEGS Paste' node."
|
||||
|
||||
@staticmethod
|
||||
def do_detail(image, segs, guide_size, guide_size_for, max_size, seed, steps, cfg, sampler_name, scheduler,
|
||||
denoise, noise_mask, force_inpaint, basic_pipe, refiner_ratio=None, batch_size=1, cycle=1,
|
||||
@@ -174,6 +176,8 @@ class SEGSPaste:
|
||||
|
||||
CATEGORY = "ImpactPack/Detailer"
|
||||
|
||||
DESCRIPTION = "This node provides a function to paste the enhanced SEGS, improved through the SEGS detailer, back onto the original image."
|
||||
|
||||
@staticmethod
|
||||
def doit(image, segs, feather, alpha=255, ref_image_opt=None):
|
||||
|
||||
@@ -1486,6 +1490,8 @@ class SEGSPicker:
|
||||
|
||||
CATEGORY = "ImpactPack/Util"
|
||||
|
||||
DESCRIPTION = "This node provides a function to select only the chosen SEGS from the input SEGS."
|
||||
|
||||
@staticmethod
|
||||
def doit(picks, segs, fallback_image_opt=None, unique_id=None):
|
||||
if fallback_image_opt is not None:
|
||||
@@ -1542,6 +1548,8 @@ class DefaultImageForSEGS:
|
||||
|
||||
CATEGORY = "ImpactPack/Util"
|
||||
|
||||
DESCRIPTION = "If the SEGS have not passed through the detailer, they contain only detection area information without an image. This node sets a default image for the SEGS."
|
||||
|
||||
@staticmethod
|
||||
def doit(segs, image, override):
|
||||
results = []
|
||||
|
||||
@@ -44,7 +44,9 @@ def read_wildcard(k, v):
|
||||
elif isinstance(v, str):
|
||||
k = wildcard_normalize(k)
|
||||
wildcard_dict[k] = [v]
|
||||
|
||||
elif isinstance(v, (int, float)):
|
||||
k = wildcard_normalize(k)
|
||||
wildcard_dict[k] = [str(v)]
|
||||
|
||||
def read_wildcard_dict(wildcard_path):
|
||||
global wildcard_dict
|
||||
@@ -135,6 +137,8 @@ def process(text, seed=None):
|
||||
b = r.group(3)
|
||||
if b is not None:
|
||||
b = b.strip()
|
||||
else:
|
||||
b = "-1"
|
||||
|
||||
if r is not None:
|
||||
if b is not None and is_numeric_string(a) and is_numeric_string(b):
|
||||
@@ -145,26 +149,32 @@ def process(text, seed=None):
|
||||
x = int(a)
|
||||
select_range = (x, x)
|
||||
|
||||
# Expand wildcard path or return the string after $$
|
||||
def expand_wildcard_or_return_string(options, pattern, wildcard_pattern):
|
||||
matches = re.findall(wildcard_pattern, pattern)
|
||||
if len(options) == 1 and matches:
|
||||
# $$<single wildcard>
|
||||
return get_wildcard_options(pattern)
|
||||
else:
|
||||
# $$opt1|opt2|...
|
||||
options[0] = pattern
|
||||
return options
|
||||
|
||||
if select_range is not None and len(multi_select_pattern) == 2:
|
||||
# PATTERN: count$$
|
||||
matches = re.findall(wildcard_pattern, multi_select_pattern[1])
|
||||
if len(options) == 1 and matches:
|
||||
# count$$<single wildcard>
|
||||
options = get_wildcard_options(multi_select_pattern[1])
|
||||
else:
|
||||
# count$$opt1|opt2|...
|
||||
options[0] = multi_select_pattern[1]
|
||||
options = expand_wildcard_or_return_string(options, multi_select_pattern[1], wildcard_pattern )
|
||||
elif select_range is not None and len(multi_select_pattern) == 3:
|
||||
# PATTERN: count$$ sep $$
|
||||
select_sep = multi_select_pattern[1]
|
||||
options[0] = multi_select_pattern[2]
|
||||
options = expand_wildcard_or_return_string(options, multi_select_pattern[2], wildcard_pattern )
|
||||
|
||||
adjusted_probabilities = []
|
||||
|
||||
total_prob = 0
|
||||
|
||||
for option in options:
|
||||
parts = option.split('::', 1)
|
||||
parts = option.split('::', 1) if isinstance(option, str) else f"{option}".split('::', 1)
|
||||
|
||||
if len(parts) == 2 and is_numeric_string(parts[0].strip()):
|
||||
config_value = float(parts[0].strip())
|
||||
else:
|
||||
@@ -178,15 +188,30 @@ def process(text, seed=None):
|
||||
if select_range is None:
|
||||
select_count = 1
|
||||
else:
|
||||
select_count = random_gen.integers(low=select_range[0], high=select_range[1]+1, size=1)
|
||||
def calculate_max(_options_length, _max_select_range):
|
||||
return min(_max_select_range + 1, _options_length + 1) if _max_select_range > 0 else _options_length + 1
|
||||
|
||||
if select_count > len(options):
|
||||
def calculate_select_count(_max_value, _min_select_range, random_gen):
|
||||
if max(_max_value, _min_select_range) <= 0:
|
||||
return 0
|
||||
# fix: low >= high
|
||||
elif _max_value == _min_select_range:
|
||||
return _max_value
|
||||
else:
|
||||
# fix: low >= high
|
||||
_low_value = min(_min_select_range, _max_value)
|
||||
_high_value = max(_min_select_range, _max_value)
|
||||
return random_gen.integers(low=_low_value, high=_high_value, size=1)
|
||||
select_count = calculate_select_count(calculate_max(len(options), select_range[1]), select_range[0], random_gen)
|
||||
|
||||
if select_count > len(options) or total_prob <= 1:
|
||||
random_gen.shuffle(options)
|
||||
selected_items = options
|
||||
else:
|
||||
selected_items = random_gen.choice(options, p=normalized_probabilities, size=select_count, replace=False)
|
||||
|
||||
selected_items2 = [re.sub(r'^\s*[0-9.]+::', '', x, 1) for x in selected_items]
|
||||
# x may be numpy.int32, convert to string
|
||||
selected_items2 = [re.sub(r'^\s*[0-9.]+::', '', str(x), 1) for x in selected_items]
|
||||
replacement = select_sep.join(selected_items2)
|
||||
if '::' in replacement:
|
||||
pass
|
||||
@@ -237,7 +262,23 @@ def process(text, seed=None):
|
||||
keyword = match.lower()
|
||||
keyword = wildcard_normalize(keyword)
|
||||
if keyword in local_wildcard_dict:
|
||||
replacement = random_gen.choice(local_wildcard_dict[keyword])
|
||||
# look for adjusted probability
|
||||
adjusted_probabilities = []
|
||||
total_prob = 0
|
||||
options=local_wildcard_dict[keyword]
|
||||
for option in options:
|
||||
parts = option.split('::', 1)
|
||||
if len(parts) == 2 and is_numeric_string(parts[0].strip()):
|
||||
config_value = float(parts[0].strip())
|
||||
else:
|
||||
config_value = 1 # Default value if no configuration is provided
|
||||
|
||||
adjusted_probabilities.append(config_value)
|
||||
total_prob += config_value
|
||||
|
||||
normalized_probabilities = [prob / total_prob for prob in adjusted_probabilities]
|
||||
selected_item = random_gen.choice(options, p=normalized_probabilities, replace=False)
|
||||
replacement = re.sub(r'^\s*[0-9.]+::', '', selected_item, 1)
|
||||
replacements_found = True
|
||||
string = string.replace(f"__{match}__", replacement, 1)
|
||||
elif '*' in keyword:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[project]
|
||||
name = "comfyui-impact-pack"
|
||||
description = "This node pack offers various detector nodes and detailer nodes that allow you to configure a workflow that automatically enhances facial details. And provide iterative upscaler."
|
||||
version = "8.4.1"
|
||||
version = "8.8.2"
|
||||
license = { file = "LICENSE.txt" }
|
||||
dependencies = ["segment-anything", "scikit-image", "piexif", "transformers", "opencv-python-headless", "GitPython", "scipy>=1.11.4"]
|
||||
|
||||
|
||||