diff --git a/py/nodes/utils.py b/py/nodes/utils.py index 604b8fe7..4be6e9a3 100644 --- a/py/nodes/utils.py +++ b/py/nodes/utils.py @@ -37,10 +37,6 @@ import os import logging import copy import folder_paths -import torch -import safetensors.torch -from diffusers.utils.state_dict_utils import convert_unet_state_dict_to_peft -from diffusers.loaders import FluxLoraLoaderMixin logger = logging.getLogger(__name__) @@ -69,6 +65,8 @@ def get_loras_list(kwargs): def load_state_dict_in_safetensors(path, device="cpu", filter_prefix=""): """Simplified version of load_state_dict_in_safetensors that just loads from a local path""" + import safetensors.torch + state_dict = {} with safetensors.torch.safe_open(path, framework="pt", device=device) as f: for k in f.keys(): @@ -79,6 +77,10 @@ def load_state_dict_in_safetensors(path, device="cpu", filter_prefix=""): def to_diffusers(input_lora): """Simplified version of to_diffusers for Flux LoRA conversion""" + import torch + from diffusers.utils.state_dict_utils import convert_unet_state_dict_to_peft + from diffusers.loaders import FluxLoraLoaderMixin + if isinstance(input_lora, str): tensors = load_state_dict_in_safetensors(input_lora, device="cpu") else: diff --git a/py/routes/recipe_routes.py b/py/routes/recipe_routes.py index ff9fabf2..393a5ae3 100644 --- a/py/routes/recipe_routes.py +++ b/py/routes/recipe_routes.py @@ -3,7 +3,6 @@ import time import base64 import numpy as np from PIL import Image -import torch import io import logging from aiohttp import web @@ -1018,6 +1017,8 @@ class RecipeRoutes: shape_info = tensor_image.shape logger.debug(f"Tensor shape: {shape_info}, dtype: {tensor_image.dtype}") + import torch + # Convert tensor to numpy array if isinstance(tensor_image, torch.Tensor): image_np = tensor_image.cpu().numpy() diff --git a/pyproject.toml b/pyproject.toml index 57309262..77693d45 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,8 +7,6 @@ dependencies = [ "aiohttp", "jinja2", "safetensors", - "diffusers", - "watchdog", "beautifulsoup4", "piexif", "Pillow", diff --git a/requirements.txt b/requirements.txt index 2dfcacde..02a7c4e0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,6 @@ aiohttp jinja2 safetensors -watchdog beautifulsoup4 piexif Pillow @@ -9,7 +8,5 @@ olefile requests toml numpy -torch natsort msgpack -diffusers>=0.33.1