Skip to content

Commit

Permalink
rename py/BiRefNet to py/BiRefNet_v2, for avoid module name conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
chflame163 committed Sep 26, 2024
1 parent ab0ec27 commit d6c576a
Show file tree
Hide file tree
Showing 38 changed files with 46 additions and 187 deletions.
142 changes: 0 additions & 142 deletions py/BiRefNet/.gitignore

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions py/BiRefNet/dataset.py → py/BiRefNet_v2/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
from torch.utils import data
from torchvision import transforms

from BiRefNet.image_proc import preproc
from BiRefNet.config import Config
from BiRefNet.utils import path_to_image
from .image_proc import preproc
from .config import Config
from .utils import path_to_image


Image.MAX_IMAGE_PIXELS = None # remove DecompressionBombWarning
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from glob import glob
import prettytable as pt

from BiRefNet.evaluation.evaluate import evaluator
from BiRefNet.config import Config
from .evaluation.evaluate import evaluator
from .config import Config


config = Config()
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from glob import glob
import numpy as np

from BiRefNet.config import Config
from .config import Config


config = Config()
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions py/BiRefNet/inference.py → py/BiRefNet_v2/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import cv2
import torch

from BiRefNet.dataset import MyData
from BiRefNet.models.birefnet import BiRefNet
from BiRefNet.utils import save_tensor_img, check_state_dict
from BiRefNet.config import Config
from .dataset import MyData
from .models.birefnet import BiRefNet
from .utils import save_tensor_img, check_state_dict
from .config import Config


config = Config()
Expand Down
2 changes: 1 addition & 1 deletion py/BiRefNet/loss.py → py/BiRefNet_v2/loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from torch.autograd import Variable
from math import exp

from BiRefNet.config import Config
from .config import Config


class Discriminator(nn.Module):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import torch.nn as nn
from collections import OrderedDict
from torchvision.models import vgg16, vgg16_bn, VGG16_Weights, VGG16_BN_Weights, resnet50, ResNet50_Weights
from BiRefNet.models.backbones.pvt_v2 import pvt_v2_b0, pvt_v2_b1, pvt_v2_b2, pvt_v2_b5
from BiRefNet.models.backbones.swin_v1 import swin_v1_t, swin_v1_s, swin_v1_b, swin_v1_l
from BiRefNet.config import Config
from ...models.backbones.pvt_v2 import pvt_v2_b0, pvt_v2_b1, pvt_v2_b2, pvt_v2_b5
from ...models.backbones.swin_v1 import swin_v1_t, swin_v1_s, swin_v1_b, swin_v1_l
from ...config import Config


config = Config()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import math

from BiRefNet.config import Config
from ...config import Config

config = Config()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import numpy as np
from timm.models.layers import DropPath, to_2tuple, trunc_normal_

from BiRefNet.config import Config
from ...config import Config


config = Config()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
from kornia.filters import laplacian
from huggingface_hub import PyTorchModelHubMixin

from BiRefNet.config import Config
from BiRefNet.dataset import class_labels_TR_sorted
from BiRefNet.models.backbones.build_backbone import build_backbone
from BiRefNet.models.modules.decoder_blocks import BasicDecBlk, ResBlk
from BiRefNet.models.modules.lateral_blocks import BasicLatBlk
from BiRefNet.models.modules.aspp import ASPP, ASPPDeformable
from BiRefNet.models.refinement.refiner import Refiner, RefinerPVTInChannels4, RefUNet
from BiRefNet.models.refinement.stem_layer import StemLayer
from ..config import Config
from ..dataset import class_labels_TR_sorted
from ..models.backbones.build_backbone import build_backbone
from ..models.modules.decoder_blocks import BasicDecBlk, ResBlk
from ..models.modules.lateral_blocks import BasicLatBlk
from ..models.modules.aspp import ASPP, ASPPDeformable
from ..models.refinement.refiner import Refiner, RefinerPVTInChannels4, RefUNet
from ..models.refinement.stem_layer import StemLayer


class BiRefNet(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import torch.nn as nn
import torch.nn.functional as F

from BiRefNet.models.modules.deform_conv import DeformableConv2d
from BiRefNet.config import Config
from ...models.modules.deform_conv import DeformableConv2d
from ...config import Config


config = Config()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import torch
import torch.nn as nn

from BiRefNet.models.modules.aspp import ASPP, ASPPDeformable
from BiRefNet.config import Config
from ...models.modules.aspp import ASPP, ASPPDeformable
from ...config import Config


config = Config()
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import torch.nn.functional as F
from functools import partial

from BiRefNet.config import Config
from ...config import Config


config = Config()
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
from torchvision.models import vgg16, vgg16_bn
from torchvision.models import resnet50

from BiRefNet.config import Config
from BiRefNet.dataset import class_labels_TR_sorted
from BiRefNet.models.backbones.build_backbone import build_backbone
from BiRefNet.models.modules.decoder_blocks import BasicDecBlk
from BiRefNet.models.modules.lateral_blocks import BasicLatBlk
from BiRefNet.models.refinement.stem_layer import StemLayer
from ...config import Config
from ...dataset import class_labels_TR_sorted
from ...models.backbones.build_backbone import build_backbone
from ...models.modules.decoder_blocks import BasicDecBlk
from ...models.modules.lateral_blocks import BasicLatBlk
from ...models.refinement.stem_layer import StemLayer


class RefinerPVTInChannels4(nn.Module):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import torch.nn as nn
from BiRefNet.models.modules.utils import build_act_layer, build_norm_layer
from ...models.modules.utils import build_act_layer, build_norm_layer


class StemLayer(nn.Module):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions py/BiRefNet/train.py → py/BiRefNet_v2/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import torch.optim as optim
from torch.autograd import Variable

from BiRefNet.config import Config
from BiRefNet.loss import PixLoss, ClsLoss
from BiRefNet.dataset import MyData
from BiRefNet.models.birefnet import BiRefNet
from BiRefNet.utils import Logger, AverageMeter, set_seed, check_state_dict
from .config import Config
from .loss import PixLoss, ClsLoss
from .dataset import MyData
from .models.birefnet import BiRefNet
from .utils import Logger, AverageMeter, set_seed, check_state_dict

from torch.utils.data.distributed import DistributedSampler
from torch.nn.parallel import DistributedDataParallel as DDP
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 4 additions & 3 deletions py/birefnet_ultra_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import tqdm
from .imagefunc import *
from comfy.utils import ProgressBar
# sys.path.append(os.path.join(os.path.dirname(__file__), 'BiRefNet'))
from .BiRefNet.models.birefnet import BiRefNet
sys.path.append(os.path.join(os.path.dirname(__file__), 'BiRefNet_v2'))


def get_models():
model_path = os.path.join(folder_paths.models_dir, 'BiRefNet', 'pth')
Expand Down Expand Up @@ -42,7 +42,8 @@ def INPUT_TYPES(s):
CATEGORY = '😺dzNodes/LayerMask'

def load_birefnet_model(self, model):
from .BiRefNet.utils import check_state_dict
from .BiRefNet_v2.models.birefnet import BiRefNet
from .BiRefNet_v2.utils import check_state_dict
model_dict = get_models()
self.birefnet = BiRefNet(bb_pretrained=False)
self.state_dict = torch.load(model_dict[model], map_location='cpu', weights_only=True)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "comfyui_layerstyle"
description = "A set of nodes for ComfyUI it generate image like Adobe Photoshop's Layer Style. the Drop Shadow is first completed node, and follow-up work is in progress."
version = "1.0.65"
version = "1.0.66"
license = "MIT"
dependencies = ["numpy", "pillow", "torch", "matplotlib", "Scipy", "scikit_image", "scikit_learn", "opencv-contrib-python", "pymatting", "segment_anything", "timm", "addict", "yapf", "colour-science", "wget", "mediapipe", "loguru", "typer_config", "fastapi", "rich", "google-generativeai", "diffusers", "omegaconf", "tqdm", "transformers", "kornia", "image-reward", "ultralytics", "blend_modes", "blind-watermark", "qrcode", "pyzbar", "transparent-background", "huggingface_hub", "accelerate", "bitsandbytes", "torchscale", "wandb", "hydra-core", "psd-tools", "inference-cli[yolo-world]", "inference-gpu[yolo-world]", "onnxruntime"]

Expand Down

0 comments on commit d6c576a

Please sign in to comment.