This commit is contained in:
chflame
2024-03-20 20:41:35 +08:00
3 changed files with 11 additions and 10 deletions
+3 -3
View File
@@ -21,17 +21,15 @@ from functools import lru_cache
from typing import Union, List
from PIL import Image, ImageFilter, ImageChops, ImageDraw, ImageOps, ImageEnhance, ImageFont
from skimage import img_as_float, img_as_ubyte
from transformers import VitMatteImageProcessor, VitMatteForImageMatting
import torchvision.transforms.functional as TF
import torch.nn.functional as F
import colorsys
import wget
from colour.io.luts.iridas_cube import read_LUT_IridasCube, LUT3D, LUT3x1D
from typing import Union
import folder_paths
from .briarmbg import BriaRMBG
from .filmgrainer import processing as processing_utils
from .filmgrainer import filmgrainer as filmgrainer
import wget
def log(message:str, message_type:str='info'):
name = 'LayerStyle'
@@ -868,6 +866,7 @@ def gamma_trans(image:Image, gamma:float) -> Image:
return cv22pil(_corrected)
def apply_lut(image:Image, lut_file:str, log:bool=False) -> Image:
from colour.io.luts.iridas_cube import read_LUT_IridasCube, LUT3D, LUT3x1D
lut: Union[LUT3x1D, LUT3D] = read_LUT_IridasCube(lut_file)
lut.name = os.path.splitext(os.path.basename(lut_file))[0] # use base filename instead of internal LUT name
@@ -1045,6 +1044,7 @@ class VITMatteModel:
self.processor = processor
def load_VITMatte_model(model_name:str) -> object:
from transformers import VitMatteForImageMatting, VitMatteImageProcessor
model = VitMatteForImageMatting.from_pretrained(model_name)
processor = VitMatteImageProcessor.from_pretrained(model_name)
vitmatte = VITMatteModel(model, processor)
+3 -3
View File
@@ -1,7 +1,6 @@
from .imagefunc import *
from functools import reduce
import wget
import mediapipe as mp
import folder_paths
from .segment_anything_func import *
@@ -47,7 +46,8 @@ class PersonMaskUltraV2:
CATEGORY = '😺dzNodes/LayerMask'
OUTPUT_NODE = True
def get_mediapipe_image(self, image: Image) -> mp.Image:
def get_mediapipe_image(self, image: Image):
import mediapipe as mp
# Convert image to NumPy array
numpy_image = np.asarray(image)
image_format = mp.ImageFormat.SRGB
@@ -63,7 +63,7 @@ class PersonMaskUltraV2:
accessories, background, confidence,
detail_method, detail_erode, detail_dilate,
black_point, white_point, process_detail):
import mediapipe as mp
a_person_mask_generator_model_path = get_a_person_mask_generator_model_path()
a_person_mask_generator_model_buffer = None
with open(a_person_mask_generator_model_path, "rb") as f:
+5 -4
View File
@@ -15,10 +15,7 @@ import folder_paths
import comfy.model_management
from sam_hq.predictor import SamPredictorHQ
from sam_hq.build_sam_hq import sam_model_registry
from local_groundingdino.datasets import transforms as T
from local_groundingdino.util.utils import clean_state_dict as local_groundingdino_clean_state_dict
from local_groundingdino.util.slconfig import SLConfig as local_groundingdino_SLConfig
from local_groundingdino.models import build_model as local_groundingdino_build_model
import glob
import folder_paths
@@ -109,6 +106,9 @@ def get_local_filepath(url, dirname, local_file_name=None):
return destination
def load_groundingdino_model(model_name):
from local_groundingdino.util.utils import clean_state_dict as local_groundingdino_clean_state_dict
from local_groundingdino.util.slconfig import SLConfig as local_groundingdino_SLConfig
from local_groundingdino.models import build_model as local_groundingdino_build_model
dino_model_args = local_groundingdino_SLConfig.fromfile(
get_local_filepath(
groundingdino_model_list[model_name]["config_url"],
@@ -142,6 +142,7 @@ def groundingdino_predict(
prompt,
threshold
):
from local_groundingdino.datasets import transforms as T
def load_dino_image(image_pil):
transform = T.Compose(
[