working install from git repo

This commit is contained in:
Benjamin Berman 2023-08-02 20:54:17 -07:00
parent 7a1f064b09
commit dc4289dbb9
18 changed files with 39 additions and 6 deletions

4
MANIFEST.in Normal file
View File

@ -0,0 +1,4 @@
recursive-include web *
recursive-include comfy/sd1_tokenizer *
include comfy/sd1_clip_config.json
include comfy/sd2_clip_config.json

0
comfy/cldm/__init__.py Normal file
View File

View File

@ -17,7 +17,7 @@ def execute_prestartup_script():
node_paths = folder_paths.get_folder_paths("custom_nodes")
for custom_node_path in node_paths:
possible_modules = os.listdir(custom_node_path)
possible_modules = os.listdir(custom_node_path) if os.path.exists(custom_node_path) else []
node_prestartup_times = []
for possible_module in possible_modules:

View File

@ -28,6 +28,7 @@ from comfy.vendor.appdirs import user_data_dir
nodes = import_all_nodes_in_workspace()
class BinaryEventTypes:
PREVIEW_IMAGE = 1
UNENCODED_PREVIEW_IMAGE = 2
@ -88,8 +89,11 @@ class PromptServer():
self.app = web.Application(client_max_size=20971520, handler_args={'max_field_size': 16380},
middlewares=middlewares)
self.sockets = dict()
self.web_root = os.path.join(os.path.dirname(
os.path.realpath(__file__)), "../../web")
web_root_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "../../web")
if not os.path.exists(web_root_path):
from pkg_resources import resource_filename
web_root_path = resource_filename('comfy', 'web/')
self.web_root = web_root_path
routes = web.RouteTableDef()
self.routes = routes
self.last_node_id = None

View File

View File

0
comfy/ldm/__init__.py Normal file
View File

View File

View File

View File

View File

@ -6,6 +6,7 @@ import torch
import traceback
import zipfile
from . import model_management
from pkg_resources import resource_filename
import contextlib
class ClipTokenWeightEncoder:
@ -52,6 +53,8 @@ class SD1ClipModel(torch.nn.Module, ClipTokenWeightEncoder):
else:
if textmodel_json_config is None:
textmodel_json_config = os.path.join(os.path.dirname(os.path.realpath(__file__)), "sd1_clip_config.json")
if not os.path.exists(textmodel_json_config):
textmodel_json_config = resource_filename('comfy', 'sd1_clip_config.json')
config = CLIPTextConfig.from_json_file(textmodel_json_config)
self.num_layers = config.num_hidden_layers
with comfy.ops.use_comfy_ops():
@ -318,6 +321,9 @@ class SD1Tokenizer:
def __init__(self, tokenizer_path=None, max_length=77, pad_with_end=True, embedding_directory=None, embedding_size=768, embedding_key='clip_l'):
if tokenizer_path is None:
tokenizer_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "sd1_tokenizer")
if not os.path.exists(os.path.join(tokenizer_path, "tokenizer_config.json")):
# package based
tokenizer_path = resource_filename('comfy', 'sd1_tokenizer/')
self.tokenizer = CLIPTokenizer.from_pretrained(tokenizer_path)
self.max_length = max_length
self.max_tokens_per_section = self.max_length - 2

View File

View File

@ -1,3 +1,5 @@
from pkg_resources import resource_filename
from comfy import sd1_clip
import torch
import os
@ -9,6 +11,8 @@ class SD2ClipModel(sd1_clip.SD1ClipModel):
layer_idx=23
textmodel_json_config = os.path.join(os.path.dirname(os.path.realpath(__file__)), "sd2_clip_config.json")
if not os.path.exists(textmodel_json_config):
textmodel_json_config = resource_filename('comfy', 'sd2_clip_config.json')
super().__init__(device=device, freeze=freeze, layer=layer, layer_idx=layer_idx, textmodel_json_config=textmodel_json_config, textmodel_path=textmodel_path)
self.empty_tokens = [[49406] + [49407] + [0] * 75]

View File

0
comfy/taesd/__init__.py Normal file
View File

1
comfy/web Symbolic link
View File

@ -0,0 +1 @@
../web

View File

@ -3,6 +3,7 @@
import os.path
import platform
import subprocess
import sys
from pip._internal.index.collector import LinkCollector
from pip._internal.index.package_finder import PackageFinder
@ -11,7 +12,7 @@ from pip._internal.models.selection_prefs import SelectionPreferences
from pip._internal.network.session import PipSession
from pip._internal.req import InstallRequirement
from pip._vendor.packaging.requirements import Requirement
from setuptools import setup, find_packages, find_namespace_packages
from setuptools import setup, find_packages
"""
The name of the package.
@ -32,7 +33,7 @@ amd_torch_index = "https://download.pytorch.org/whl/rocm5.4.2"
The package index to torch built with CUDA.
Observe the CUDA version is in this URL.
"""
nvidia_torch_index = "https://download.pytorch.org/whl/cu118"
nvidia_torch_index = "https://download.pytorch.org/whl/nightly/cu118"
"""
The package index to torch built against CPU features.
@ -47,6 +48,12 @@ Packages that should have a specific option set when a GPU accelerator is presen
"""
gpu_accelerated_packages = {"rembg": "rembg[gpu]"}
"""
Indicates if we're installing an editable (develop) mode package
"""
is_editable = '--editable' in sys.argv or '-e' in sys.argv or (
'python' in sys.argv and 'setup.py' in sys.argv and 'develop' in sys.argv)
def _is_nvidia() -> bool:
system = platform.system().lower()
@ -137,6 +144,9 @@ def dependencies() -> [str]:
return _dependencies
package_data = ['sd1_tokenizer/*', '**/*.json']
if not is_editable:
package_data.append('web/**/*')
setup(
# "comfyui"
name=package_name,
@ -146,7 +156,8 @@ setup(
python_requires=">=3.9,<3.12",
# todo: figure out how to include the web directory to eventually let main live inside the package
# todo: see https://packaging.python.org/en/latest/guides/creating-and-discovering-plugins/ for more about adding plugins
packages=find_packages(where="comfy") + find_packages(where="comfy_extras"),
packages=find_packages(exclude=[] if is_editable else ['custom_nodes']),
include_package_data=True,
install_requires=dependencies(),
setup_requires=["pip", "wheel"],
entry_points={
@ -155,4 +166,7 @@ setup(
'comfyui = comfy.cmd.main:main'
],
},
package_data={
'comfy': package_data
},
)