├── .DS_Store ├── LICENSE ├── README.md ├── __init__.py ├── example └── example_colorpalette.json ├── nodes ├── .gitignore └── APQNodes.py └── src └── ColorPalette_nodes_info.jpg /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AIPOQUE/ComfyUI-APQNodes/25a7aea3379259f9189a21e56a0160b6f8f8d02c/.DS_Store -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 AIPOQUE 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ComfyUI APQNodes 2 | 3 | ## Introduction 4 | Without fine-tuning, FLUX.1 Dev model cannot understand exact color codes. 5 | However, it is known that FLUX.1 Dev can repeatedly produce certain colors with certain prompt(color name). 6 | Fortunately, on CIVITAI, [“novuschroma” shared 155 pre-tested color names](https://civitai.com/models/879997/color-wildcards-for-flux-and-sdxl) that FLUX.1 Dev can handle. 7 | Thanks to his resource, color palette consists exclusively of 155 colors can be configured. 8 | ‘ColorPalette’ node from ComfyUI APQNodes converts input hex color code to the most similar color name(from pre-tested 155 color names) of which FLUX.1 Dev is aware. 9 | 10 | 11 | ## Installation 12 | Clone this repo into `custom_nodes` folder. 13 | 14 | 15 | ## Usage 16 | ‘ColorPalette’ node consists of two inputs and two outputs. 17 | ![ColorPalette Node](https://github.com/AIPOQUE/ComfyUI-APQNodes/blob/main/src/ColorPalette_nodes_info.jpg) 18 | 19 | * __Inputs__ 20 | * __prompt__ : User text prompt 21 | * __hexcodes__ : any text hex color codes without any delimiter. For example, #FF0000 #00FF00 #0000FF can generate color palette consisting of 3 colors(RED, BLUE, GREEN) 22 | 23 | * __Outputs__ 24 | * __Prompt__ : Text prompt(User text prompt with color palettes applied) to connect to CLIP Text Encode. 25 | * __solor_palettes__ : Image of generated color palette 26 | -------------------------------------------------------------------------------- /__init__.py: -------------------------------------------------------------------------------- 1 | from .nodes.APQNodes import * 2 | 3 | 4 | NODE_CLASS_MAPPINGS = { 5 | "ColorPalette|AIPOQUE": ColorPalette 6 | } 7 | 8 | NODE_DISPLAY_NAME_MAPPINGS = { 9 | "ColorPalette|AIPOQUE": "ColorPalette" 10 | } -------------------------------------------------------------------------------- /example/example_colorpalette.json: -------------------------------------------------------------------------------- 1 | { 2 | "last_node_id": 35, 3 | "last_link_id": 35, 4 | "nodes": [ 5 | { 6 | "id": 3, 7 | "type": "VAELoader", 8 | "pos": { 9 | "0": 53, 10 | "1": 419 11 | }, 12 | "size": { 13 | "0": 315, 14 | "1": 58 15 | }, 16 | "flags": {}, 17 | "order": 0, 18 | "mode": 0, 19 | "inputs": [], 20 | "outputs": [ 21 | { 22 | "name": "VAE", 23 | "type": "VAE", 24 | "links": [ 25 | 7 26 | ], 27 | "slot_index": 0 28 | } 29 | ], 30 | "properties": { 31 | "Node name for S&R": "VAELoader" 32 | }, 33 | "widgets_values": [ 34 | "vae_flux.safetensors" 35 | ] 36 | }, 37 | { 38 | "id": 6, 39 | "type": "ConditioningZeroOut", 40 | "pos": { 41 | "0": 403, 42 | "1": 269 43 | }, 44 | "size": { 45 | "0": 317.4000244140625, 46 | "1": 26 47 | }, 48 | "flags": { 49 | "collapsed": true 50 | }, 51 | "order": 13, 52 | "mode": 0, 53 | "inputs": [ 54 | { 55 | "name": "conditioning", 56 | "type": "CONDITIONING", 57 | "link": 5 58 | } 59 | ], 60 | "outputs": [ 61 | { 62 | "name": "CONDITIONING", 63 | "type": "CONDITIONING", 64 | "links": [ 65 | 3 66 | ], 67 | "slot_index": 0 68 | } 69 | ], 70 | "properties": { 71 | "Node name for S&R": "ConditioningZeroOut" 72 | }, 73 | "widgets_values": [] 74 | }, 75 | { 76 | "id": 1, 77 | "type": "UNETLoader", 78 | "pos": { 79 | "0": 54, 80 | "1": 120 81 | }, 82 | "size": { 83 | "0": 315, 84 | "1": 82 85 | }, 86 | "flags": {}, 87 | "order": 1, 88 | "mode": 0, 89 | "inputs": [], 90 | "outputs": [ 91 | { 92 | "name": "MODEL", 93 | "type": "MODEL", 94 | "links": [ 95 | 1 96 | ], 97 | "slot_index": 0 98 | } 99 | ], 100 | "properties": { 101 | "Node name for S&R": "UNETLoader" 102 | }, 103 | "widgets_values": [ 104 | "flux1-dev-fp8.safetensors", 105 | "default" 106 | ] 107 | }, 108 | { 109 | "id": 2, 110 | "type": "DualCLIPLoader", 111 | "pos": { 112 | "0": 57, 113 | "1": 252 114 | }, 115 | "size": { 116 | "0": 315, 117 | "1": 106 118 | }, 119 | "flags": {}, 120 | "order": 2, 121 | "mode": 0, 122 | "inputs": [], 123 | "outputs": [ 124 | { 125 | "name": "CLIP", 126 | "type": "CLIP", 127 | "links": [ 128 | 4 129 | ], 130 | "slot_index": 0 131 | } 132 | ], 133 | "properties": { 134 | "Node name for S&R": "DualCLIPLoader" 135 | }, 136 | "widgets_values": [ 137 | "t5xxl_fp8_e4m3fn.safetensors", 138 | "clip_l.safetensors", 139 | "flux" 140 | ] 141 | }, 142 | { 143 | "id": 12, 144 | "type": "SDXLEmptyLatentSizePicker+", 145 | "pos": { 146 | "0": 51, 147 | "1": 533 148 | }, 149 | "size": { 150 | "0": 340.20001220703125, 151 | "1": 170 152 | }, 153 | "flags": {}, 154 | "order": 3, 155 | "mode": 0, 156 | "inputs": [], 157 | "outputs": [ 158 | { 159 | "name": "LATENT", 160 | "type": "LATENT", 161 | "links": [ 162 | 9 163 | ], 164 | "slot_index": 0 165 | }, 166 | { 167 | "name": "width", 168 | "type": "INT", 169 | "links": null 170 | }, 171 | { 172 | "name": "height", 173 | "type": "INT", 174 | "links": null 175 | } 176 | ], 177 | "properties": { 178 | "Node name for S&R": "SDXLEmptyLatentSizePicker+" 179 | }, 180 | "widgets_values": [ 181 | "1024x1024 (1.0)", 182 | 1, 183 | 0, 184 | 0 185 | ] 186 | }, 187 | { 188 | "id": 10, 189 | "type": "LoadImage", 190 | "pos": { 191 | "0": 133.26759338378906, 192 | "1": -526.5546264648438 193 | }, 194 | "size": { 195 | "0": 315, 196 | "1": 314 197 | }, 198 | "flags": {}, 199 | "order": 4, 200 | "mode": 0, 201 | "inputs": [], 202 | "outputs": [ 203 | { 204 | "name": "IMAGE", 205 | "type": "IMAGE", 206 | "links": [ 207 | 30 208 | ], 209 | "slot_index": 0 210 | }, 211 | { 212 | "name": "MASK", 213 | "type": "MASK", 214 | "links": null 215 | } 216 | ], 217 | "properties": { 218 | "Node name for S&R": "LoadImage" 219 | }, 220 | "widgets_values": [ 221 | "color-palette-4501.png", 222 | "image" 223 | ] 224 | }, 225 | { 226 | "id": 21, 227 | "type": "Text List to Text", 228 | "pos": { 229 | "0": 783.453369140625, 230 | "1": -520.2236328125 231 | }, 232 | "size": { 233 | "0": 315, 234 | "1": 58 235 | }, 236 | "flags": {}, 237 | "order": 8, 238 | "mode": 0, 239 | "inputs": [ 240 | { 241 | "name": "text_list", 242 | "type": "LIST", 243 | "link": 20 244 | } 245 | ], 246 | "outputs": [ 247 | { 248 | "name": "STRING", 249 | "type": "STRING", 250 | "links": [ 251 | 21, 252 | 33 253 | ], 254 | "slot_index": 0 255 | } 256 | ], 257 | "properties": { 258 | "Node name for S&R": "Text List to Text" 259 | }, 260 | "widgets_values": [ 261 | ", " 262 | ] 263 | }, 264 | { 265 | "id": 4, 266 | "type": "KSampler", 267 | "pos": { 268 | "0": 398, 269 | "1": 327 270 | }, 271 | "size": { 272 | "0": 315, 273 | "1": 262 274 | }, 275 | "flags": {}, 276 | "order": 14, 277 | "mode": 0, 278 | "inputs": [ 279 | { 280 | "name": "model", 281 | "type": "MODEL", 282 | "link": 1 283 | }, 284 | { 285 | "name": "positive", 286 | "type": "CONDITIONING", 287 | "link": 2 288 | }, 289 | { 290 | "name": "negative", 291 | "type": "CONDITIONING", 292 | "link": 3 293 | }, 294 | { 295 | "name": "latent_image", 296 | "type": "LATENT", 297 | "link": 9 298 | } 299 | ], 300 | "outputs": [ 301 | { 302 | "name": "LATENT", 303 | "type": "LATENT", 304 | "links": [ 305 | 6 306 | ], 307 | "slot_index": 0 308 | } 309 | ], 310 | "properties": { 311 | "Node name for S&R": "KSampler" 312 | }, 313 | "widgets_values": [ 314 | 0, 315 | "fixed", 316 | 20, 317 | 1, 318 | "euler", 319 | "normal", 320 | 1 321 | ] 322 | }, 323 | { 324 | "id": 5, 325 | "type": "CLIPTextEncode", 326 | "pos": { 327 | "0": 403, 328 | "1": 222 329 | }, 330 | "size": [ 331 | 323.522705078125, 332 | 181.83770751953125 333 | ], 334 | "flags": { 335 | "collapsed": true 336 | }, 337 | "order": 11, 338 | "mode": 0, 339 | "inputs": [ 340 | { 341 | "name": "clip", 342 | "type": "CLIP", 343 | "link": 4 344 | }, 345 | { 346 | "name": "text", 347 | "type": "STRING", 348 | "link": 34, 349 | "widget": { 350 | "name": "text" 351 | } 352 | } 353 | ], 354 | "outputs": [ 355 | { 356 | "name": "CONDITIONING", 357 | "type": "CONDITIONING", 358 | "links": [ 359 | 2, 360 | 5 361 | ], 362 | "slot_index": 0 363 | } 364 | ], 365 | "properties": { 366 | "Node name for S&R": "CLIPTextEncode" 367 | }, 368 | "widgets_values": [ 369 | "" 370 | ] 371 | }, 372 | { 373 | "id": 7, 374 | "type": "VAEDecode", 375 | "pos": { 376 | "0": 731, 377 | "1": 331 378 | }, 379 | "size": { 380 | "0": 210, 381 | "1": 46 382 | }, 383 | "flags": {}, 384 | "order": 15, 385 | "mode": 0, 386 | "inputs": [ 387 | { 388 | "name": "samples", 389 | "type": "LATENT", 390 | "link": 6 391 | }, 392 | { 393 | "name": "vae", 394 | "type": "VAE", 395 | "link": 7 396 | } 397 | ], 398 | "outputs": [ 399 | { 400 | "name": "IMAGE", 401 | "type": "IMAGE", 402 | "links": [ 403 | 8 404 | ], 405 | "slot_index": 0 406 | } 407 | ], 408 | "properties": { 409 | "Node name for S&R": "VAEDecode" 410 | }, 411 | "widgets_values": [] 412 | }, 413 | { 414 | "id": 8, 415 | "type": "PreviewImage", 416 | "pos": { 417 | "0": 950, 418 | "1": 328 419 | }, 420 | "size": { 421 | "0": 399.3075256347656, 422 | "1": 415.4858703613281 423 | }, 424 | "flags": {}, 425 | "order": 16, 426 | "mode": 0, 427 | "inputs": [ 428 | { 429 | "name": "images", 430 | "type": "IMAGE", 431 | "link": 8 432 | } 433 | ], 434 | "outputs": [], 435 | "properties": { 436 | "Node name for S&R": "PreviewImage" 437 | }, 438 | "widgets_values": [] 439 | }, 440 | { 441 | "id": 34, 442 | "type": "CR Text", 443 | "pos": { 444 | "0": 395, 445 | "1": -32 446 | }, 447 | "size": { 448 | "0": 400, 449 | "1": 200 450 | }, 451 | "flags": {}, 452 | "order": 5, 453 | "mode": 0, 454 | "inputs": [], 455 | "outputs": [ 456 | { 457 | "name": "text", 458 | "type": "*", 459 | "links": [ 460 | 32 461 | ], 462 | "slot_index": 0 463 | }, 464 | { 465 | "name": "show_help", 466 | "type": "STRING", 467 | "links": null 468 | } 469 | ], 470 | "properties": { 471 | "Node name for S&R": "CR Text" 472 | }, 473 | "widgets_values": [ 474 | "3D rendering of an office in vibrant colors." 475 | ] 476 | }, 477 | { 478 | "id": 17, 479 | "type": "Image Color Palette", 480 | "pos": { 481 | "0": 462.9938049316406, 482 | "1": -530.5311889648438 483 | }, 484 | "size": { 485 | "0": 315, 486 | "1": 102 487 | }, 488 | "flags": {}, 489 | "order": 6, 490 | "mode": 0, 491 | "inputs": [ 492 | { 493 | "name": "image", 494 | "type": "IMAGE", 495 | "link": 30 496 | } 497 | ], 498 | "outputs": [ 499 | { 500 | "name": "image", 501 | "type": "IMAGE", 502 | "links": [ 503 | 16 504 | ], 505 | "slot_index": 0 506 | }, 507 | { 508 | "name": "color_palettes", 509 | "type": "LIST", 510 | "links": [ 511 | 20 512 | ], 513 | "slot_index": 1 514 | } 515 | ], 516 | "properties": { 517 | "Node name for S&R": "Image Color Palette" 518 | }, 519 | "widgets_values": [ 520 | 8, 521 | "back_to_back" 522 | ] 523 | }, 524 | { 525 | "id": 33, 526 | "type": "ColorPalette|AIPOQUE", 527 | "pos": { 528 | "0": 820, 529 | "1": -25 530 | }, 531 | "size": [ 532 | 303.8149811955434, 533 | 57.809067536525504 534 | ], 535 | "flags": {}, 536 | "order": 10, 537 | "mode": 0, 538 | "inputs": [ 539 | { 540 | "name": "prompt", 541 | "type": "STRING", 542 | "link": 32, 543 | "widget": { 544 | "name": "prompt" 545 | } 546 | }, 547 | { 548 | "name": "hexcodes", 549 | "type": "STRING", 550 | "link": 33, 551 | "widget": { 552 | "name": "hexcodes" 553 | } 554 | } 555 | ], 556 | "outputs": [ 557 | { 558 | "name": "prompt", 559 | "type": "STRING", 560 | "links": [ 561 | 34 562 | ], 563 | "slot_index": 0 564 | }, 565 | { 566 | "name": "color_palettes", 567 | "type": "IMAGE", 568 | "links": [ 569 | 35 570 | ], 571 | "slot_index": 1 572 | } 573 | ], 574 | "properties": { 575 | "Node name for S&R": "ColorPalette|AIPOQUE" 576 | }, 577 | "widgets_values": [ 578 | "Hello", 579 | "World" 580 | ] 581 | }, 582 | { 583 | "id": 22, 584 | "type": "ShowText|pysssss", 585 | "pos": { 586 | "0": 794.471435546875, 587 | "1": -416.6806640625 588 | }, 589 | "size": { 590 | "0": 318.46380615234375, 591 | "1": 179.38487243652344 592 | }, 593 | "flags": {}, 594 | "order": 9, 595 | "mode": 0, 596 | "inputs": [ 597 | { 598 | "name": "text", 599 | "type": "STRING", 600 | "link": 21, 601 | "widget": { 602 | "name": "text" 603 | } 604 | } 605 | ], 606 | "outputs": [ 607 | { 608 | "name": "STRING", 609 | "type": "STRING", 610 | "links": null, 611 | "shape": 6 612 | } 613 | ], 614 | "properties": { 615 | "Node name for S&R": "ShowText|pysssss" 616 | }, 617 | "widgets_values": [ 618 | "", 619 | "#ad696a\n#d08584\n#e9a7a7\n#e5c3c3\n#f7e0df\n#f8f5f5\n#97dcdb\n#ddeceb" 620 | ] 621 | }, 622 | { 623 | "id": 35, 624 | "type": "PreviewImage", 625 | "pos": { 626 | "0": 1138, 627 | "1": -1 628 | }, 629 | "size": [ 630 | 442.129879578991, 631 | 127.49194092872835 632 | ], 633 | "flags": {}, 634 | "order": 12, 635 | "mode": 0, 636 | "inputs": [ 637 | { 638 | "name": "images", 639 | "type": "IMAGE", 640 | "link": 35 641 | } 642 | ], 643 | "outputs": [], 644 | "properties": { 645 | "Node name for S&R": "PreviewImage" 646 | } 647 | }, 648 | { 649 | "id": 18, 650 | "type": "PreviewImage", 651 | "pos": { 652 | "0": 463, 653 | "1": -391 654 | }, 655 | "size": [ 656 | 325.3026573188249, 657 | 135.45500507887053 658 | ], 659 | "flags": {}, 660 | "order": 7, 661 | "mode": 0, 662 | "inputs": [ 663 | { 664 | "name": "images", 665 | "type": "IMAGE", 666 | "link": 16 667 | } 668 | ], 669 | "outputs": [], 670 | "properties": { 671 | "Node name for S&R": "PreviewImage" 672 | }, 673 | "widgets_values": [] 674 | } 675 | ], 676 | "links": [ 677 | [ 678 | 1, 679 | 1, 680 | 0, 681 | 4, 682 | 0, 683 | "MODEL" 684 | ], 685 | [ 686 | 2, 687 | 5, 688 | 0, 689 | 4, 690 | 1, 691 | "CONDITIONING" 692 | ], 693 | [ 694 | 3, 695 | 6, 696 | 0, 697 | 4, 698 | 2, 699 | "CONDITIONING" 700 | ], 701 | [ 702 | 4, 703 | 2, 704 | 0, 705 | 5, 706 | 0, 707 | "CLIP" 708 | ], 709 | [ 710 | 5, 711 | 5, 712 | 0, 713 | 6, 714 | 0, 715 | "CONDITIONING" 716 | ], 717 | [ 718 | 6, 719 | 4, 720 | 0, 721 | 7, 722 | 0, 723 | "LATENT" 724 | ], 725 | [ 726 | 7, 727 | 3, 728 | 0, 729 | 7, 730 | 1, 731 | "VAE" 732 | ], 733 | [ 734 | 8, 735 | 7, 736 | 0, 737 | 8, 738 | 0, 739 | "IMAGE" 740 | ], 741 | [ 742 | 9, 743 | 12, 744 | 0, 745 | 4, 746 | 3, 747 | "LATENT" 748 | ], 749 | [ 750 | 16, 751 | 17, 752 | 0, 753 | 18, 754 | 0, 755 | "IMAGE" 756 | ], 757 | [ 758 | 20, 759 | 17, 760 | 1, 761 | 21, 762 | 0, 763 | "LIST" 764 | ], 765 | [ 766 | 21, 767 | 21, 768 | 0, 769 | 22, 770 | 0, 771 | "STRING" 772 | ], 773 | [ 774 | 30, 775 | 10, 776 | 0, 777 | 17, 778 | 0, 779 | "IMAGE" 780 | ], 781 | [ 782 | 32, 783 | 34, 784 | 0, 785 | 33, 786 | 0, 787 | "STRING" 788 | ], 789 | [ 790 | 33, 791 | 21, 792 | 0, 793 | 33, 794 | 1, 795 | "STRING" 796 | ], 797 | [ 798 | 34, 799 | 33, 800 | 0, 801 | 5, 802 | 1, 803 | "STRING" 804 | ], 805 | [ 806 | 35, 807 | 33, 808 | 1, 809 | 35, 810 | 0, 811 | "IMAGE" 812 | ] 813 | ], 814 | "groups": [], 815 | "config": {}, 816 | "extra": { 817 | "ds": { 818 | "scale": 0.6588450000000011, 819 | "offset": [ 820 | 303.7125359360359, 821 | 460.22966088960425 822 | ] 823 | } 824 | }, 825 | "version": 0.4 826 | } -------------------------------------------------------------------------------- /nodes/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .venv -------------------------------------------------------------------------------- /nodes/APQNodes.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import torch 3 | from PIL import Image, ImageDraw 4 | 5 | class ColorPalette: 6 | def __init__(self): 7 | pass 8 | 9 | @classmethod 10 | def INPUT_TYPES(cls): 11 | return {"required": { 12 | "prompt": ("STRING", {"multiline": False, "default": "Hello", "forceInput":True}), 13 | "hexcodes": ("STRING", {"multiline": False, "default": "World", "forceInput":True}),} 14 | } 15 | 16 | RETURN_TYPES = ("STRING", "IMAGE",) 17 | RETURN_NAMES = ("prompt", "color_palettes",) 18 | FUNCTION = "color_picker" 19 | CATEGORY = "APQNodes/Color" 20 | def color_picker(self, prompt, hexcodes): 21 | splited = hexcodes.split("#") 22 | treated = [] 23 | for i in splited: 24 | ii = i.replace("\n", "").strip() 25 | if len(i)>0: 26 | treated.append(ii) 27 | closest_color = [] 28 | color_list_final = "" 29 | color_list = [[(250, 112, 96), ['coral', '#FA7060']], [(173, 176, 176), ['gray', '#ADB0B0']], [(251, 211, 150), ['sepia', '#FBD396']], [(247, 208, 149), ['buff', '#F7D095']], [(254, 198, 165), ['peach', '#FEC6A5']], [(103, 1, 6), ['maroon', '#670106']], [(252, 252, 251), ['white', '#FCFCFB']], [(53, 208, 66), ['may green', '#35D042']], [(164, 65, 28), ['cocoa', '#A4411C']], [(248, 7, 24), ['carmine', '#F80718']], [(21, 226, 229), ['cyan', '#15E2E5']], [(152, 233, 188), ['celadon', '#98E9BC']], [(6, 152, 226), ['yinmn blue', '#0698E2']], [(0, 30, 92), ['indigo', '#001E5C']], [(168, 167, 165), ['nickel', '#A8A7A5']], [(0, 129, 206), ['dodgerblue', '#0081CE']], [(254, 83, 159), ['hot pink', '#FE539F']], [(0, 27, 69), ['navy blue', '#001B45']], [(8, 177, 233), ['blue', '#08B1E9']], [(250, 194, 126), ['sandy brown', '#FAC27E']], [(1, 94, 162), ['savoy blue', '#015EA2']], [(253, 196, 123), ['tan', '#FDC47B']], [(88, 251, 41), ['spring green', '#58FB29']], [(241, 119, 1), ['amber', '#F17701']], [(91, 100, 4), ['olive green', '#5B6404']], [(102, 0, 111), ['plum purple', '#66006F']], [(187, 9, 103), ['mulberry', '#BB0967']], [(134, 15, 110), ['eggplant', '#860F6E']], [(210, 143, 250), ['wisteria purple', '#D28FFA']], [(254, 246, 114), ['lemon chiffon', '#FEF672']], [(254, 182, 132), ['melon', '#FEB684']], [(254, 180, 5), ['yellow orange', '#FEB405']], [(121, 0, 85), ['aubergine', '#790055']], [(251, 118, 0), ['orange', '#FB7600']], [(173, 0, 37), ['amaranth', '#AD0025']], [(254, 215, 174), ['bisque', '#FED7AE']], [(5, 9, 12), ['ebony', '#05090C']], [(249, 88, 143), ['deep pink', '#F9588F']], [(133, 0, 24), ['burgundy', '#850018']], [(224, 40, 1), ['rust', '#E02801']], [(246, 111, 3), ['persimmon', '#F66F03']], [(0, 87, 192), ['prussian blue', '#0057C0']], [(221, 142, 19), ['brass', '#DD8E13']], [(147, 25, 199), ['purple', '#9319C7']], [(93, 155, 192), ['blue gray', '#5D9BC0']], [(248, 105, 133), ['puce', '#F86985']], [(6, 197, 107), ['caribbean green', '#06C56B']], [(250, 114, 11), ['burnt sienna', '#FA720B']], [(25, 123, 41), ['hunter green', '#197B29']], [(188, 74, 5), ['russet', '#BC4A05']], [(196, 158, 106), ['khaki', '#C49E6A']], [(228, 191, 249), ['lilac', '#E4BFF9']], [(4, 177, 111), ['jade', '#04B16F']], [(0, 29, 76), ['midnight blue', '#001D4C']], [(70, 78, 83), ['slate gray', '#464E53']], [(254, 203, 5), ['goldenrod', '#FECB05']], [(15, 18, 22), ['charcoal', '#0F1216']], [(209, 210, 210), ['silver', '#D1D2D2']], [(20, 197, 176), ['teal', '#14C5B0']], [(0, 145, 74), ['emerald green', '#00914A']], [(165, 45, 215), ['violet', '#A52DD7']], [(146, 229, 249), ['powder blue', '#92E5F9']], [(99, 244, 237), ['aquamarine', '#63F4ED']], [(148, 0, 30), ['claret', '#94001E']], [(254, 230, 106), ['honeydew', '#FEE66A']], [(27, 207, 226), ['cerulean', '#1BCFE2']], [(218, 191, 247), ['lavender', '#DABFF7']], [(254, 218, 3), ['cadmium yellow', '#FEDA03']], [(136, 0, 12), ['oxblood', '#88000C']], [(229, 176, 29), ['gold', '#E5B01D']], [(146, 20, 180), ['amethyst purple', '#9214B4']], [(254, 165, 119), ['rosegold', '#FEA577']], [(241, 11, 134), ['magenta', '#F10B86']], [(203, 0, 3), ['venetian red', '#CB0003']], [(0, 95, 197), ['ultramarine blue', '#005FC5']], [(155, 252, 199), ['mint green', '#9BFCC7']], [(38, 184, 75), ['persian green', '#26B84B']], [(254, 132, 3), ['tangerine orange', '#FE8403']], [(134, 92, 38), ['bronze', '#865C26']], [(29, 31, 40), ['onyx', '#1D1F28']], [(1, 1, 1), ['black', '#010101']], [(105, 226, 252), ['sky blue', '#69E2FC']], [(90, 224, 183), ['sea green', '#5AE0B7']], [(215, 108, 119), ['mauve', '#D76C77']], [(16, 159, 215), ['pacific blue', '#109FD7']], [(81, 49, 228), ['blue violet', '#5131E4']], [(0, 92, 214), ['royal blue', '#005CD6']], [(254, 188, 5), ['saffron', '#FEBC05']], [(252, 222, 0), ['yellow', '#FCDE00']], [(240, 98, 18), ['umber', '#F06212']], [(254, 171, 199), ['pink', '#FEABC7']], [(254, 177, 113), ['apricot', '#FEB171']], [(107, 33, 8), ['chocolate', '#6B2108']], [(244, 239, 228), ['linen', '#F4EFE4']], [(147, 0, 32), ['wine', '#930020']], [(93, 0, 81), ['plum', '#5D0051']], [(162, 254, 16), ['lime green', '#A2FE10']], [(253, 228, 198), ['blanched almond', '#FDE4C6']], [(159, 221, 176), ['sage', '#9FDDB0']], [(157, 25, 2), ['mahogany', '#9D1902']], [(84, 196, 254), ['cornflower blue', '#54C4FE']], [(254, 187, 0), ['turmeric', '#FEBB00']], [(94, 0, 113), ['tyrian purple', '#5E0071']], [(43, 241, 220), ['turquoise', '#2BF1DC']], [(222, 187, 149), ['taupe', '#DEBB95']], [(252, 49, 6), ['carnelian', '#FC3106']], [(254, 192, 195), ['blush', '#FEC0C3']], [(138, 229, 250), ['alice blue', '#8AE5FA']], [(81, 39, 11), ['pullman brown', '#51270B']], [(0, 56, 176), ['lapis lazuli', '#0038B0']], [(254, 193, 50), ['aureolin', '#FEC132']], [(199, 103, 40), ['saddlebrown', '#C76728']], [(254, 66, 7), ['orange red', '#FE4207']], [(254, 205, 23), ['maize', '#FECD17']], [(0, 73, 202), ['cobalt blue', '#0049CA']], [(200, 88, 23), ['chestnut', '#C85817']], [(254, 230, 107), ['cornsilk', '#FEE66B']], [(112, 0, 180), ['royal purple', '#7000B4']], [(231, 86, 28), ['copper', '#E7561C']], [(252, 96, 41), ['terra cotta', '#FC6029']], [(211, 0, 0), ['scarlet', '#D30000']], [(225, 0, 0), ['red', '#E10000']], [(252, 240, 211), ['cream', '#FCF0D3']], [(233, 0, 1), ['vermilion', '#E90001']], [(182, 61, 205), ['rebecca purple', '#B63DCD']], [(138, 238, 236), ['robin egg blue', '#8AEEEC']], [(254, 239, 208), ['vanilla', '#FEEFD0']], [(252, 141, 41), ['sienna', '#FC8D29']], [(254, 66, 119), ['cerise', '#FE4277']], [(250, 238, 220), ['alabaster', '#FAEEDC']], [(160, 237, 254), ['baby blue', '#A0EDFE']], [(250, 225, 187), ['beige', '#FAE1BB']], [(243, 35, 138), ['jazzberry jam', '#F3238A']], [(254, 174, 195), ['carnation pink', '#FEAEC3']], [(164, 246, 229), ['seafoam', '#A4F6E5']], [(246, 148, 2), ['ochre', '#F69402']], [(249, 125, 77), ['salmon', '#F97D4D']], [(2, 171, 65), ['viridian', '#02AB41']], [(254, 217, 158), ['sand', '#FED99E']], [(254, 81, 17), ['rufous', '#FE5111']], [(248, 240, 211), ['ivory', '#F8F0D3']], [(179, 111, 205), ['heliotrope', '#B36FCD']], [(248, 247, 238), ['antique white', '#F8F7EE']], [(13, 89, 132), ['slate blue', '#0D5984']], [(254, 200, 60), ['citrine', '#FEC83C']], [(159, 165, 168), ['ash gray', '#9FA5A8']], [(153, 71, 12), ['brown', '#99470C']], [(150, 188, 250), ['periwinkle', '#96BCFA']], [(55, 223, 66), ['green', '#37DF42']], [(254, 159, 54), ['caramel', '#FE9F36']], [(210, 254, 20), ['yellow green', '#D2FE14']], [(185, 254, 0), ['chartreuse', '#B9FE00']], [(194, 0, 0), ['crimson', '#C20000']], [(249, 184, 0), ['mustard', '#F9B800']], [(254, 240, 27), ['lemon yellow', '#FEF01B']]] 30 | 31 | for hex in treated: 32 | res = [[999, ["comparison_color", "FFFFFF"]]] 33 | value = hex.lstrip("#") 34 | lv = len(value) 35 | rgb = tuple(int(value[i:i + lv // 3], 16) for i in range(0, lv, lv // 3)) 36 | for i in color_list: 37 | reading_r, reading_g, reading_b = i[0][0], i[0][1], i[0][2] 38 | gap = abs(reading_r - rgb[0]) + abs(reading_g - rgb[1]) + abs(reading_b - rgb[2]) 39 | if res[-1][0] > gap: 40 | res.append([gap, i[1]]) 41 | closest_color.append(res[-1]) 42 | color_list_final += res[-1][1][0]+", " 43 | numofcolors = len(closest_color) 44 | restriction_statement = f"The colors are restricted to following {numofcolors} colors: {color_list_final}" 45 | text_out = prompt + "\n" + restriction_statement 46 | image_width = 64*numofcolors 47 | image_height = 64 48 | background_color = "#ffffff" 49 | canvas = Image.new("RGBA", (image_width, image_height), background_color) 50 | draw = ImageDraw.Draw(canvas) 51 | for i in range(numofcolors): 52 | draw.rectangle([(64*i, 0), (64*(i+1), 64)], fill=(closest_color[i][1][1])) 53 | image_out = torch.from_numpy(np.array(canvas).astype(np.float32) / 255.0).unsqueeze(0) 54 | return (text_out, image_out) 55 | -------------------------------------------------------------------------------- /src/ColorPalette_nodes_info.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AIPOQUE/ComfyUI-APQNodes/25a7aea3379259f9189a21e56a0160b6f8f8d02c/src/ColorPalette_nodes_info.jpg --------------------------------------------------------------------------------