refactor: Remove unused imports and dependencies from utils, recipe_routes, requirements, and pyproject files. See #278

This commit is contained in:
Will Miao
2025-07-10 16:36:28 +08:00
parent 854e8bf356
commit a6f04c6d7e
4 changed files with 8 additions and 10 deletions

View File

@@ -37,10 +37,6 @@ import os
import logging import logging
import copy import copy
import folder_paths 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__) logger = logging.getLogger(__name__)
@@ -69,6 +65,8 @@ def get_loras_list(kwargs):
def load_state_dict_in_safetensors(path, device="cpu", filter_prefix=""): 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""" """Simplified version of load_state_dict_in_safetensors that just loads from a local path"""
import safetensors.torch
state_dict = {} state_dict = {}
with safetensors.torch.safe_open(path, framework="pt", device=device) as f: with safetensors.torch.safe_open(path, framework="pt", device=device) as f:
for k in f.keys(): 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): def to_diffusers(input_lora):
"""Simplified version of to_diffusers for Flux LoRA conversion""" """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): if isinstance(input_lora, str):
tensors = load_state_dict_in_safetensors(input_lora, device="cpu") tensors = load_state_dict_in_safetensors(input_lora, device="cpu")
else: else:

View File

@@ -3,7 +3,6 @@ import time
import base64 import base64
import numpy as np import numpy as np
from PIL import Image from PIL import Image
import torch
import io import io
import logging import logging
from aiohttp import web from aiohttp import web
@@ -1018,6 +1017,8 @@ class RecipeRoutes:
shape_info = tensor_image.shape shape_info = tensor_image.shape
logger.debug(f"Tensor shape: {shape_info}, dtype: {tensor_image.dtype}") logger.debug(f"Tensor shape: {shape_info}, dtype: {tensor_image.dtype}")
import torch
# Convert tensor to numpy array # Convert tensor to numpy array
if isinstance(tensor_image, torch.Tensor): if isinstance(tensor_image, torch.Tensor):
image_np = tensor_image.cpu().numpy() image_np = tensor_image.cpu().numpy()

View File

@@ -7,8 +7,6 @@ dependencies = [
"aiohttp", "aiohttp",
"jinja2", "jinja2",
"safetensors", "safetensors",
"diffusers",
"watchdog",
"beautifulsoup4", "beautifulsoup4",
"piexif", "piexif",
"Pillow", "Pillow",

View File

@@ -1,7 +1,6 @@
aiohttp aiohttp
jinja2 jinja2
safetensors safetensors
watchdog
beautifulsoup4 beautifulsoup4
piexif piexif
Pillow Pillow
@@ -9,7 +8,5 @@ olefile
requests requests
toml toml
numpy numpy
torch
natsort natsort
msgpack msgpack
diffusers>=0.33.1