mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-01-10 18:05:16 +00:00
Lint unused import (#5973)
* Lint unused import * nit * Remove unused imports * revert fix_torch import * nit
This commit is contained in:
parent
e2fafe0686
commit
0fd4e6c778
@ -1,3 +1,3 @@
|
|||||||
[MESSAGES CONTROL]
|
[MESSAGES CONTROL]
|
||||||
disable=all
|
disable=all
|
||||||
enable=eval-used
|
enable=eval-used, unused-import
|
||||||
|
@ -2,11 +2,9 @@
|
|||||||
#and modified
|
#and modified
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
import torch as th
|
|
||||||
import torch.nn as nn
|
import torch.nn as nn
|
||||||
|
|
||||||
from ..ldm.modules.diffusionmodules.util import (
|
from ..ldm.modules.diffusionmodules.util import (
|
||||||
zero_module,
|
|
||||||
timestep_embedding,
|
timestep_embedding,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
import math
|
import math
|
||||||
from typing import List, Optional, Tuple
|
from typing import List, Optional, Tuple
|
||||||
|
|
||||||
import numpy as np
|
|
||||||
import torch
|
import torch
|
||||||
import torch.nn as nn
|
import torch.nn as nn
|
||||||
from einops import rearrange
|
|
||||||
from torch import Tensor
|
from torch import Tensor
|
||||||
|
|
||||||
from comfy.ldm.modules.diffusionmodules.mmdit import DismantledBlock, PatchEmbed, VectorEmbedder, TimestepEmbedder, get_2d_sincos_pos_embed_torch
|
from comfy.ldm.modules.diffusionmodules.mmdit import DismantledBlock, PatchEmbed, VectorEmbedder, TimestepEmbedder, get_2d_sincos_pos_embed_torch
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import torch
|
import torch
|
||||||
from typing import Dict, Optional
|
from typing import Optional
|
||||||
import comfy.ldm.modules.diffusionmodules.mmdit
|
import comfy.ldm.modules.diffusionmodules.mmdit
|
||||||
|
|
||||||
class ControlNet(comfy.ldm.modules.diffusionmodules.mmdit.MMDiT):
|
class ControlNet(comfy.ldm.modules.diffusionmodules.mmdit.MMDiT):
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
#code taken from: https://github.com/wl-zhao/UniPC and modified
|
#code taken from: https://github.com/wl-zhao/UniPC and modified
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
import torch.nn.functional as F
|
|
||||||
import math
|
import math
|
||||||
|
|
||||||
from tqdm.auto import trange, tqdm
|
from tqdm.auto import trange
|
||||||
|
|
||||||
|
|
||||||
class NoiseScheduleVP:
|
class NoiseScheduleVP:
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import torch
|
import torch
|
||||||
from torch import nn
|
from torch import nn
|
||||||
from typing import Literal, Dict, Any
|
from typing import Literal
|
||||||
import math
|
import math
|
||||||
import comfy.ops
|
import comfy.ops
|
||||||
ops = comfy.ops.disable_weight_init
|
ops = comfy.ops.disable_weight_init
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
import torch
|
import torch
|
||||||
import torch.nn as nn
|
import torch.nn as nn
|
||||||
from torch import Tensor, einsum
|
from torch import Tensor
|
||||||
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, TypeVar, Union
|
from typing import List, Union
|
||||||
from einops import rearrange
|
from einops import rearrange
|
||||||
import math
|
import math
|
||||||
import comfy.ops
|
import comfy.ops
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import torch
|
|
||||||
import torchvision
|
import torchvision
|
||||||
from torch import nn
|
from torch import nn
|
||||||
from .common import LayerNorm2d_op
|
from .common import LayerNorm2d_op
|
||||||
|
@ -6,9 +6,7 @@ import math
|
|||||||
from torch import Tensor, nn
|
from torch import Tensor, nn
|
||||||
from einops import rearrange, repeat
|
from einops import rearrange, repeat
|
||||||
|
|
||||||
from .layers import (DoubleStreamBlock, EmbedND, LastLayer,
|
from .layers import (timestep_embedding)
|
||||||
MLPEmbedder, SingleStreamBlock,
|
|
||||||
timestep_embedding)
|
|
||||||
|
|
||||||
from .model import Flux
|
from .model import Flux
|
||||||
import comfy.ldm.common_dit
|
import comfy.ldm.common_dit
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#original code from https://github.com/genmoai/models under apache 2.0 license
|
#original code from https://github.com/genmoai/models under apache 2.0 license
|
||||||
#adapted to ComfyUI
|
#adapted to ComfyUI
|
||||||
|
|
||||||
from typing import Optional, Tuple
|
from typing import Optional
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
import torch.nn as nn
|
import torch.nn as nn
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#original code from https://github.com/genmoai/models under apache 2.0 license
|
#original code from https://github.com/genmoai/models under apache 2.0 license
|
||||||
#adapted to ComfyUI
|
#adapted to ComfyUI
|
||||||
|
|
||||||
from typing import Callable, List, Optional, Tuple, Union
|
from typing import List, Optional, Tuple, Union
|
||||||
from functools import partial
|
from functools import partial
|
||||||
import math
|
import math
|
||||||
|
|
||||||
|
@ -1,24 +1,17 @@
|
|||||||
from typing import Any, Optional
|
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
import torch.nn as nn
|
import torch.nn as nn
|
||||||
import torch.nn.functional as F
|
|
||||||
|
|
||||||
from torch.utils import checkpoint
|
|
||||||
|
|
||||||
from comfy.ldm.modules.diffusionmodules.mmdit import (
|
from comfy.ldm.modules.diffusionmodules.mmdit import (
|
||||||
Mlp,
|
|
||||||
TimestepEmbedder,
|
TimestepEmbedder,
|
||||||
PatchEmbed,
|
PatchEmbed,
|
||||||
RMSNorm,
|
|
||||||
)
|
)
|
||||||
from comfy.ldm.modules.diffusionmodules.util import timestep_embedding
|
|
||||||
from .poolers import AttentionPool
|
from .poolers import AttentionPool
|
||||||
|
|
||||||
import comfy.latent_formats
|
import comfy.latent_formats
|
||||||
from .models import HunYuanDiTBlock, calc_rope
|
from .models import HunYuanDiTBlock, calc_rope
|
||||||
|
|
||||||
from .posemb_layers import get_2d_rotary_pos_embed, get_fill_resize_and_crop
|
|
||||||
|
|
||||||
|
|
||||||
class HunYuanControlNet(nn.Module):
|
class HunYuanControlNet(nn.Module):
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
from typing import Any
|
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
import torch.nn as nn
|
import torch.nn as nn
|
||||||
import torch.nn.functional as F
|
|
||||||
|
|
||||||
import comfy.ops
|
import comfy.ops
|
||||||
from comfy.ldm.modules.diffusionmodules.mmdit import Mlp, TimestepEmbedder, PatchEmbed, RMSNorm
|
from comfy.ldm.modules.diffusionmodules.mmdit import Mlp, TimestepEmbedder, PatchEmbed, RMSNorm
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import torch
|
import torch
|
||||||
import torch.nn as nn
|
import torch.nn as nn
|
||||||
import torch.nn.functional as F
|
|
||||||
from comfy.ldm.modules.attention import optimized_attention
|
from comfy.ldm.modules.attention import optimized_attention
|
||||||
import comfy.ops
|
import comfy.ops
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ from torch import nn
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
import math
|
import math
|
||||||
from einops import rearrange
|
from einops import rearrange
|
||||||
from typing import Any, Mapping, Optional, Tuple, Union, List
|
from typing import Optional, Tuple, Union
|
||||||
from .conv_nd_factory import make_conv_nd, make_linear_nd
|
from .conv_nd_factory import make_conv_nd, make_linear_nd
|
||||||
from .pixel_norm import PixelNorm
|
from .pixel_norm import PixelNorm
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
from typing import Tuple, Union
|
from typing import Tuple, Union
|
||||||
|
|
||||||
import torch
|
|
||||||
|
|
||||||
from .dual_conv3d import DualConv3d
|
from .dual_conv3d import DualConv3d
|
||||||
from .causal_conv3d import CausalConv3d
|
from .causal_conv3d import CausalConv3d
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import torch
|
import torch
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
from typing import Any, Dict, List, Optional, Tuple, Union
|
from typing import Any, Dict, Tuple, Union
|
||||||
|
|
||||||
from comfy.ldm.modules.distributions.distributions import DiagonalGaussianDistribution
|
from comfy.ldm.modules.distributions.distributions import DiagonalGaussianDistribution
|
||||||
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
import logging
|
|
||||||
import math
|
|
||||||
from typing import Dict, Optional, List
|
from typing import Dict, Optional, List
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
@ -3,7 +3,6 @@ import math
|
|||||||
import torch
|
import torch
|
||||||
import torch.nn as nn
|
import torch.nn as nn
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from typing import Optional, Any
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from comfy import model_management
|
from comfy import model_management
|
||||||
|
@ -9,7 +9,6 @@ import logging
|
|||||||
from .util import (
|
from .util import (
|
||||||
checkpoint,
|
checkpoint,
|
||||||
avg_pool_nd,
|
avg_pool_nd,
|
||||||
zero_module,
|
|
||||||
timestep_embedding,
|
timestep_embedding,
|
||||||
AlphaBlender,
|
AlphaBlender,
|
||||||
)
|
)
|
||||||
|
@ -4,7 +4,6 @@ import numpy as np
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from .util import extract_into_tensor, make_beta_schedule
|
from .util import extract_into_tensor, make_beta_schedule
|
||||||
from comfy.ldm.util import default
|
|
||||||
|
|
||||||
|
|
||||||
class AbstractLowScaleModel(nn.Module):
|
class AbstractLowScaleModel(nn.Module):
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
# thanks!
|
# thanks!
|
||||||
|
|
||||||
|
|
||||||
import os
|
|
||||||
import math
|
import math
|
||||||
import torch
|
import torch
|
||||||
import torch.nn as nn
|
import torch.nn as nn
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import functools
|
import functools
|
||||||
from typing import Callable, Iterable, Union
|
from typing import Iterable, Union
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
from einops import rearrange, repeat
|
from einops import rearrange, repeat
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
import uuid
|
import uuid
|
||||||
import torch
|
|
||||||
import comfy.model_management
|
import comfy.model_management
|
||||||
import comfy.conds
|
import comfy.conds
|
||||||
import comfy.utils
|
import comfy.utils
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import os
|
|
||||||
import torch
|
import torch
|
||||||
|
|
||||||
class SPieceTokenizer:
|
class SPieceTokenizer:
|
||||||
|
@ -2,8 +2,7 @@ import comfy.samplers
|
|||||||
import comfy.utils
|
import comfy.utils
|
||||||
import torch
|
import torch
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from tqdm.auto import trange, tqdm
|
from tqdm.auto import trange
|
||||||
import math
|
|
||||||
|
|
||||||
|
|
||||||
@torch.no_grad()
|
@torch.no_grad()
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import torch
|
|
||||||
from nodes import MAX_RESOLUTION
|
from nodes import MAX_RESOLUTION
|
||||||
|
|
||||||
class CLIPTextEncodeSDXLRefiner:
|
class CLIPTextEncodeSDXLRefiner:
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import numpy as np
|
|
||||||
import torch
|
import torch
|
||||||
import comfy.utils
|
import comfy.utils
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
@ -4,7 +4,6 @@ import torch
|
|||||||
from collections.abc import Iterable
|
from collections.abc import Iterable
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from comfy.model_patcher import ModelPatcher
|
|
||||||
from comfy.sd import CLIP
|
from comfy.sd import CLIP
|
||||||
|
|
||||||
import comfy.hooks
|
import comfy.hooks
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import folder_paths
|
|
||||||
import comfy.sd
|
import comfy.sd
|
||||||
import comfy.model_sampling
|
import comfy.model_sampling
|
||||||
import comfy.latent_formats
|
import comfy.latent_formats
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import torch
|
|
||||||
import comfy.utils
|
import comfy.utils
|
||||||
|
|
||||||
class PatchModelAddDownscale:
|
class PatchModelAddDownscale:
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import os
|
|
||||||
import logging
|
import logging
|
||||||
from spandrel import ModelLoader, ImageModelDescriptor
|
from spandrel import ModelLoader, ImageModelDescriptor
|
||||||
from comfy import model_management
|
from comfy import model_management
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
from PIL import Image, ImageOps
|
from PIL import Image
|
||||||
from io import BytesIO
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import struct
|
|
||||||
import comfy.utils
|
import comfy.utils
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ from comfy_execution.graph import get_input_info, ExecutionList, DynamicPrompt,
|
|||||||
from comfy_execution.graph_utils import is_link, GraphBuilder
|
from comfy_execution.graph_utils import is_link, GraphBuilder
|
||||||
from comfy_execution.caching import HierarchicalCache, LRUCache, CacheKeySetInputSignature, CacheKeySetID
|
from comfy_execution.caching import HierarchicalCache, LRUCache, CacheKeySetInputSignature, CacheKeySetID
|
||||||
from comfy_execution.validation import validate_node_input
|
from comfy_execution.validation import validate_node_input
|
||||||
from comfy.cli_args import args
|
|
||||||
|
|
||||||
class ExecutionResult(Enum):
|
class ExecutionResult(Enum):
|
||||||
SUCCESS = 0
|
SUCCESS = 0
|
||||||
|
36
fix_torch.py
36
fix_torch.py
@ -5,20 +5,24 @@ import ctypes
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
|
||||||
torch_spec = importlib.util.find_spec("torch")
|
def fix_pytorch_libomp():
|
||||||
for folder in torch_spec.submodule_search_locations:
|
"""
|
||||||
lib_folder = os.path.join(folder, "lib")
|
Fix PyTorch libomp DLL issue on Windows by copying the correct DLL file if needed.
|
||||||
test_file = os.path.join(lib_folder, "fbgemm.dll")
|
"""
|
||||||
dest = os.path.join(lib_folder, "libomp140.x86_64.dll")
|
torch_spec = importlib.util.find_spec("torch")
|
||||||
if os.path.exists(dest):
|
for folder in torch_spec.submodule_search_locations:
|
||||||
break
|
lib_folder = os.path.join(folder, "lib")
|
||||||
|
test_file = os.path.join(lib_folder, "fbgemm.dll")
|
||||||
with open(test_file, 'rb') as f:
|
dest = os.path.join(lib_folder, "libomp140.x86_64.dll")
|
||||||
contents = f.read()
|
if os.path.exists(dest):
|
||||||
if b"libomp140.x86_64.dll" not in contents:
|
|
||||||
break
|
break
|
||||||
try:
|
|
||||||
mydll = ctypes.cdll.LoadLibrary(test_file)
|
with open(test_file, "rb") as f:
|
||||||
except FileNotFoundError as e:
|
contents = f.read()
|
||||||
logging.warning("Detected pytorch version with libomp issue, patching.")
|
if b"libomp140.x86_64.dll" not in contents:
|
||||||
shutil.copyfile(os.path.join(lib_folder, "libiomp5md.dll"), dest)
|
break
|
||||||
|
try:
|
||||||
|
mydll = ctypes.cdll.LoadLibrary(test_file)
|
||||||
|
except FileNotFoundError as e:
|
||||||
|
logging.warning("Detected pytorch version with libomp issue, patching.")
|
||||||
|
shutil.copyfile(os.path.join(lib_folder, "libiomp5md.dll"), dest)
|
||||||
|
@ -4,7 +4,7 @@ import os
|
|||||||
import time
|
import time
|
||||||
import mimetypes
|
import mimetypes
|
||||||
import logging
|
import logging
|
||||||
from typing import Set, List, Dict, Tuple, Literal
|
from typing import Literal
|
||||||
from collections.abc import Collection
|
from collections.abc import Collection
|
||||||
|
|
||||||
supported_pt_extensions: set[str] = {'.ckpt', '.pt', '.bin', '.pth', '.safetensors', '.pkl', '.sft'}
|
supported_pt_extensions: set[str] = {'.ckpt', '.pt', '.bin', '.pth', '.safetensors', '.pkl', '.sft'}
|
||||||
@ -133,7 +133,7 @@ def get_directory_by_type(type_name: str) -> str | None:
|
|||||||
return get_input_directory()
|
return get_input_directory()
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def filter_files_content_types(files: List[str], content_types: Literal["image", "video", "audio"]) -> List[str]:
|
def filter_files_content_types(files: list[str], content_types: Literal["image", "video", "audio"]) -> list[str]:
|
||||||
"""
|
"""
|
||||||
Example:
|
Example:
|
||||||
files = os.listdir(folder_paths.get_input_directory())
|
files = os.listdir(folder_paths.get_input_directory())
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
import torch
|
import torch
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
import struct
|
|
||||||
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 comfy.model_management
|
import comfy.model_management
|
||||||
|
3
main.py
3
main.py
@ -87,7 +87,8 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
if args.windows_standalone_build:
|
if args.windows_standalone_build:
|
||||||
try:
|
try:
|
||||||
import fix_torch
|
from fix_torch import fix_pytorch_libomp
|
||||||
|
fix_pytorch_libomp()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import json
|
import json
|
||||||
from urllib import request, parse
|
from urllib import request
|
||||||
import random
|
|
||||||
|
|
||||||
#This is the ComfyUI api prompt format.
|
#This is the ComfyUI api prompt format.
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from urllib import request
|
|
||||||
import numpy
|
import numpy
|
||||||
import os
|
import os
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
Loading…
Reference in New Issue
Block a user