mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-02-15 07:52:35 +08:00
wip
This commit is contained in:
parent
82d0edf121
commit
3d3c5ae344
@ -7,7 +7,7 @@ supported_pt_extensions = set(['.ckpt', '.pt', '.bin', '.pth', '.safetensors'])
|
|||||||
folder_names_and_paths = {}
|
folder_names_and_paths = {}
|
||||||
|
|
||||||
base_path = os.path.dirname(os.path.realpath(__file__))
|
base_path = os.path.dirname(os.path.realpath(__file__))
|
||||||
models_dir = os.path.join(base_path, "models")
|
models_dir = os.path.join(base_path, "../../models")
|
||||||
folder_names_and_paths["checkpoints"] = ([os.path.join(models_dir, "checkpoints")], supported_ckpt_extensions)
|
folder_names_and_paths["checkpoints"] = ([os.path.join(models_dir, "checkpoints")], supported_ckpt_extensions)
|
||||||
folder_names_and_paths["configs"] = ([os.path.join(models_dir, "configs")], [".yaml"])
|
folder_names_and_paths["configs"] = ([os.path.join(models_dir, "configs")], [".yaml"])
|
||||||
|
|
||||||
@ -26,13 +26,13 @@ folder_names_and_paths["gligen"] = ([os.path.join(models_dir, "gligen")], suppor
|
|||||||
|
|
||||||
folder_names_and_paths["upscale_models"] = ([os.path.join(models_dir, "upscale_models")], supported_pt_extensions)
|
folder_names_and_paths["upscale_models"] = ([os.path.join(models_dir, "upscale_models")], supported_pt_extensions)
|
||||||
|
|
||||||
folder_names_and_paths["custom_nodes"] = ([os.path.join(base_path, "custom_nodes")], [])
|
folder_names_and_paths["custom_nodes"] = ([os.path.join(base_path, "../../custom_nodes")], [])
|
||||||
|
|
||||||
folder_names_and_paths["hypernetworks"] = ([os.path.join(models_dir, "hypernetworks")], supported_pt_extensions)
|
folder_names_and_paths["hypernetworks"] = ([os.path.join(models_dir, "hypernetworks")], supported_pt_extensions)
|
||||||
|
|
||||||
output_directory = os.path.join(os.path.dirname(os.path.realpath(__file__)), "output")
|
output_directory = os.path.realpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../../output"))
|
||||||
temp_directory = os.path.join(os.path.dirname(os.path.realpath(__file__)), "temp")
|
temp_directory = os.path.join(os.path.dirname(os.path.realpath(__file__)), "temp")
|
||||||
input_directory = os.path.join(os.path.dirname(os.path.realpath(__file__)), "input")
|
input_directory = os.path.realpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../../input"))
|
||||||
|
|
||||||
filename_list_cache = {}
|
filename_list_cache = {}
|
||||||
|
|
||||||
@ -1,10 +1,9 @@
|
|||||||
import torch
|
import torch
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
import struct
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from comfy.cli_args import args, LatentPreviewMethod
|
from comfy.cli_args import args, LatentPreviewMethod
|
||||||
from comfy.taesd.taesd import TAESD
|
from comfy.taesd.taesd import TAESD
|
||||||
import folder_paths
|
from ..cmd import folder_paths
|
||||||
|
|
||||||
MAX_PREVIEW_RESOLUTION = 512
|
MAX_PREVIEW_RESOLUTION = 512
|
||||||
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import importlib.util
|
import importlib.util
|
||||||
import folder_paths
|
from ..cmd import folder_paths
|
||||||
import time
|
import time
|
||||||
|
|
||||||
def execute_prestartup_script():
|
def execute_prestartup_script():
|
||||||
@ -56,23 +56,21 @@ if os.name == "nt":
|
|||||||
import logging
|
import logging
|
||||||
logging.getLogger("xformers").addFilter(lambda record: 'A matching Triton is not available' not in record.getMessage())
|
logging.getLogger("xformers").addFilter(lambda record: 'A matching Triton is not available' not in record.getMessage())
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
if args.cuda_device is not None:
|
if args.cuda_device is not None:
|
||||||
os.environ['CUDA_VISIBLE_DEVICES'] = str(args.cuda_device)
|
os.environ['CUDA_VISIBLE_DEVICES'] = str(args.cuda_device)
|
||||||
print("Set cuda device to:", args.cuda_device)
|
print("Set cuda device to:", args.cuda_device)
|
||||||
|
|
||||||
import cuda_malloc
|
|
||||||
|
|
||||||
import comfy.utils
|
import comfy.utils
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
import execution
|
from ..cmd import execution
|
||||||
import server
|
from ..cmd import server as server_module
|
||||||
from server import BinaryEventTypes
|
from .server import BinaryEventTypes
|
||||||
import comfy.model_management
|
import comfy.model_management
|
||||||
|
|
||||||
|
|
||||||
def prompt_worker(q: execution.PromptQueue, _server: server.PromptServer):
|
def prompt_worker(q: execution.PromptQueue, _server: server_module.PromptServer):
|
||||||
e = execution.PromptExecutor(_server)
|
e = execution.PromptExecutor(_server)
|
||||||
while True:
|
while True:
|
||||||
item, item_id = q.get()
|
item, item_id = q.get()
|
||||||
@ -80,8 +78,8 @@ def prompt_worker(q: execution.PromptQueue, _server: server.PromptServer):
|
|||||||
prompt_id = item[1]
|
prompt_id = item[1]
|
||||||
e.execute(item[2], prompt_id, item[3], item[4])
|
e.execute(item[2], prompt_id, item[3], item[4])
|
||||||
q.task_done(item_id, e.outputs_ui)
|
q.task_done(item_id, e.outputs_ui)
|
||||||
if server.client_id is not None:
|
if _server.client_id is not None:
|
||||||
server.send_sync("executing", { "node": None, "prompt_id": prompt_id }, server.client_id)
|
_server.send_sync("executing", { "node": None, "prompt_id": prompt_id }, _server.client_id)
|
||||||
|
|
||||||
print("Prompt executed in {:.2f} seconds".format(time.perf_counter() - execution_start_time))
|
print("Prompt executed in {:.2f} seconds".format(time.perf_counter() - execution_start_time))
|
||||||
gc.collect()
|
gc.collect()
|
||||||
@ -126,12 +124,12 @@ def load_extra_path_config(yaml_path):
|
|||||||
folder_paths.add_model_folder_path(x, full_path)
|
folder_paths.add_model_folder_path(x, full_path)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
def main():
|
||||||
cleanup_temp()
|
cleanup_temp()
|
||||||
|
|
||||||
loop = asyncio.new_event_loop()
|
loop = asyncio.new_event_loop()
|
||||||
asyncio.set_event_loop(loop)
|
asyncio.set_event_loop(loop)
|
||||||
server = server.PromptServer(loop)
|
server = server_module.PromptServer(loop)
|
||||||
q = execution.PromptQueue(server)
|
q = execution.PromptQueue(server)
|
||||||
|
|
||||||
extra_model_paths_config_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "extra_model_paths.yaml")
|
extra_model_paths_config_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "extra_model_paths.yaml")
|
||||||
@ -15,8 +15,8 @@ import aiofiles
|
|||||||
import aiohttp
|
import aiohttp
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
|
|
||||||
import execution
|
from ..cmd import execution
|
||||||
import folder_paths
|
from ..cmd import folder_paths
|
||||||
import mimetypes
|
import mimetypes
|
||||||
|
|
||||||
from comfy.digest import digest
|
from comfy.digest import digest
|
||||||
@ -89,7 +89,7 @@ class PromptServer():
|
|||||||
middlewares=middlewares)
|
middlewares=middlewares)
|
||||||
self.sockets = dict()
|
self.sockets = dict()
|
||||||
self.web_root = os.path.join(os.path.dirname(
|
self.web_root = os.path.join(os.path.dirname(
|
||||||
os.path.realpath(__file__)), "web")
|
os.path.realpath(__file__)), "../../web")
|
||||||
routes = web.RouteTableDef()
|
routes = web.RouteTableDef()
|
||||||
self.routes = routes
|
self.routes = routes
|
||||||
self.last_node_id = None
|
self.last_node_id = None
|
||||||
@ -140,7 +140,7 @@ class PromptServer():
|
|||||||
def get_dir_by_type(dir_type=None):
|
def get_dir_by_type(dir_type=None):
|
||||||
type_dir = ""
|
type_dir = ""
|
||||||
if dir_type is None:
|
if dir_type is None:
|
||||||
dir_type = "input"
|
dir_type = "../../input"
|
||||||
|
|
||||||
if dir_type == "input":
|
if dir_type == "input":
|
||||||
type_dir = folder_paths.get_input_directory()
|
type_dir = folder_paths.get_input_directory()
|
||||||
@ -732,7 +732,7 @@ class PromptServer():
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_upload_dir(cls) -> str:
|
def get_upload_dir(cls) -> str:
|
||||||
upload_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "input")
|
upload_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "../../input")
|
||||||
|
|
||||||
if not os.path.exists(upload_dir):
|
if not os.path.exists(upload_dir):
|
||||||
os.makedirs(upload_dir)
|
os.makedirs(upload_dir)
|
||||||
@ -1,13 +1,11 @@
|
|||||||
import json
|
import json
|
||||||
import os
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
import folder_paths
|
from .cmd import folder_paths
|
||||||
from comfy.sd import load_checkpoint
|
from comfy.sd import load_checkpoint
|
||||||
import os.path as osp
|
import os.path as osp
|
||||||
import re
|
|
||||||
import torch
|
import torch
|
||||||
from safetensors.torch import load_file, save_file
|
from safetensors.torch import load_file
|
||||||
from . import diffusers_convert
|
from . import diffusers_convert
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,9 @@
|
|||||||
import torch
|
import torch
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
|
||||||
import json
|
import json
|
||||||
import hashlib
|
import hashlib
|
||||||
import traceback
|
|
||||||
import math
|
import math
|
||||||
import time
|
|
||||||
import random
|
import random
|
||||||
|
|
||||||
from PIL import Image, ImageOps
|
from PIL import Image, ImageOps
|
||||||
@ -25,10 +22,7 @@ import comfy.clip_vision
|
|||||||
import comfy.model_management
|
import comfy.model_management
|
||||||
from comfy.cli_args import args
|
from comfy.cli_args import args
|
||||||
|
|
||||||
import importlib
|
from comfy.cmd import folder_paths, latent_preview
|
||||||
|
|
||||||
import folder_paths
|
|
||||||
import latent_preview
|
|
||||||
from comfy.nodes.common import MAX_RESOLUTION
|
from comfy.nodes.common import MAX_RESOLUTION
|
||||||
|
|
||||||
|
|
||||||
@ -690,7 +684,8 @@ class CLIPLoader:
|
|||||||
class DualCLIPLoader:
|
class DualCLIPLoader:
|
||||||
@classmethod
|
@classmethod
|
||||||
def INPUT_TYPES(s):
|
def INPUT_TYPES(s):
|
||||||
return {"required": { "clip_name1": (folder_paths.get_filename_list("clip"), ), "clip_name2": (folder_paths.get_filename_list("clip"), ),
|
return {"required": { "clip_name1": (folder_paths.get_filename_list("clip"),), "clip_name2": (
|
||||||
|
folder_paths.get_filename_list("clip"),),
|
||||||
}}
|
}}
|
||||||
RETURN_TYPES = ("CLIP",)
|
RETURN_TYPES = ("CLIP",)
|
||||||
FUNCTION = "load_clip"
|
FUNCTION = "load_clip"
|
||||||
@ -5,9 +5,13 @@ import pkgutil
|
|||||||
import time
|
import time
|
||||||
import types
|
import types
|
||||||
|
|
||||||
import nodes as base_nodes
|
from comfy.nodes import base_nodes as base_nodes
|
||||||
from comfy_extras import nodes as comfy_extras_nodes
|
from comfy_extras import nodes as comfy_extras_nodes
|
||||||
|
|
||||||
|
try:
|
||||||
import custom_nodes
|
import custom_nodes
|
||||||
|
except:
|
||||||
|
custom_nodes = None
|
||||||
from comfy.nodes.package_typing import ExportedNodes
|
from comfy.nodes.package_typing import ExportedNodes
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
|
|
||||||
@ -68,7 +72,8 @@ def import_all_nodes_in_workspace() -> ExportedNodes:
|
|||||||
comfy_extras_nodes
|
comfy_extras_nodes
|
||||||
]),
|
]),
|
||||||
ExportedNodes())
|
ExportedNodes())
|
||||||
|
custom_nodes_mappings = ExportedNodes()
|
||||||
|
if custom_nodes is not None:
|
||||||
custom_nodes_mappings = _import_and_enumerate_nodes_in_module(custom_nodes, print_import_times=True)
|
custom_nodes_mappings = _import_and_enumerate_nodes_in_module(custom_nodes, print_import_times=True)
|
||||||
|
|
||||||
# don't allow custom nodes to overwrite base nodes
|
# don't allow custom nodes to overwrite base nodes
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import comfy.utils
|
import comfy.utils
|
||||||
import folder_paths
|
from comfy.cmd import folder_paths
|
||||||
import torch
|
import torch
|
||||||
|
|
||||||
def load_hypernetwork_patch(path, strength):
|
def load_hypernetwork_patch(path, strength):
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import comfy.sd
|
|||||||
import comfy.utils
|
import comfy.utils
|
||||||
import comfy.model_base
|
import comfy.model_base
|
||||||
|
|
||||||
import folder_paths
|
from comfy.cmd import folder_paths
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
import os
|
|
||||||
from comfy_extras.chainner_models import model_loading
|
from comfy_extras.chainner_models import model_loading
|
||||||
from comfy import model_management
|
from comfy import model_management
|
||||||
import torch
|
import torch
|
||||||
import comfy.utils
|
import comfy.utils
|
||||||
import folder_paths
|
from comfy.cmd import folder_paths
|
||||||
|
|
||||||
|
|
||||||
class UpscaleModelLoader:
|
class UpscaleModelLoader:
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
4
setup.py
4
setup.py
@ -151,8 +151,8 @@ setup(
|
|||||||
setup_requires=["pip", "wheel"],
|
setup_requires=["pip", "wheel"],
|
||||||
entry_points={
|
entry_points={
|
||||||
'console_scripts': [
|
'console_scripts': [
|
||||||
# todo: eventually migrate main here
|
'comfyui-openapi-gen = comfy.cmd.openapi_gen:main',
|
||||||
'comfyui-openapi-gen = comfy.cmd.openapi_gen:main'
|
'comfyui = comfy.cmd.main:main'
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user