Merge branch 'master' into patch-1

This commit is contained in:
ArtemM
2023-11-01 21:10:40 +01:00
committed by GitHub
3 changed files with 14 additions and 4 deletions
+3 -2
View File
@@ -15,10 +15,11 @@ from custom_nodes.facerestore_cf.basicsr.utils.registry import ARCH_REGISTRY
# import codeformer_arch
dir_facerestore_models = os.path.join(folder_paths.models_dir, "facerestore_models")
dir_facedetection = os.path.join(folder_paths.models_dir, "facedetection")
dir_facedetection_models = os.path.join(folder_paths.models_dir, "facedetection")
os.makedirs(dir_facerestore_models, exist_ok=True)
os.makedirs(dir_facedetection, exist_ok=True)
os.makedirs(dir_facedetection_models, exist_ok=True)
folder_paths.folder_names_and_paths["facerestore_models"] = ([dir_facerestore_models], folder_paths.supported_pt_extensions)
folder_paths.folder_names_and_paths["facedetection_models"] = ([dir_facedetection_models], folder_paths.supported_pt_extensions)
def img2tensor(imgs, bgr2rgb=True, float32=True):
"""Numpy array to tensor.
+4 -2
View File
@@ -5,13 +5,15 @@ import torch.nn as nn
import torch.nn.functional as F
from PIL import Image
from torchvision.models._utils import IntermediateLayerGetter as IntermediateLayerGetter
from comfy import model_management
from custom_nodes.facerestore_cf.facelib.detection.align_trans import get_reference_facial_points, warp_and_crop_face
from custom_nodes.facerestore_cf.facelib.detection.retinaface.retinaface_net import FPN, SSH, MobileNetV1, make_bbox_head, make_class_head, make_landmark_head
from custom_nodes.facerestore_cf.facelib.detection.retinaface.retinaface_utils import (PriorBox, batched_decode, batched_decode_landm, decode, decode_landm,
py_cpu_nms)
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
# device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
device = model_management.get_torch_device()
def generate_config(network_name):
+7
View File
@@ -4,6 +4,8 @@ import os.path as osp
import torch
from torch.hub import download_url_to_file, get_dir
from urllib.parse import urlparse
import folder_paths
# from custom_nodes.facerestore_cf.basicsr.utils.download_util import download_file_from_google_drive
#import gdown
@@ -96,6 +98,11 @@ def load_file_from_url(url, model_dir=None, progress=True, file_name=None):
filename = os.path.basename(parts.path)
if file_name is not None:
filename = file_name
model_path = folder_paths.get_full_path("facedetection_models", filename)
if model_path:
return model_path
cached_file = os.path.abspath(os.path.join(ROOT_DIR, model_dir, filename))
if not os.path.exists(cached_file):
print(f'Downloading: "{url}" to {cached_file}\n')