suport more version BiRefNet models
This commit is contained in:
@@ -9,6 +9,11 @@
|
||||
|
||||
本仓库将BiRefNet最新模型封装为ComfyUI节点来使用,相较于旧模型,最新模型的抠图精度更高更好。<br>
|
||||
|
||||
|
||||
## 🔥🔥🔥 更新!!
|
||||
|
||||
* 2025年02月17日: 🚀 支持多个版本BiRefNet模型,比如 [BiRefNet](https://huggingface.co/ZhengPeng7/BiRefNet) 、[BiRefNet_HR](https://huggingface.co/ZhengPeng7/BiRefNet_HR) 、 [BiRefNet-portrait](https://huggingface.co/ZhengPeng7/BiRefNet-portrait) 。
|
||||
|
||||
## 安装
|
||||
|
||||
#### 方法1:
|
||||
|
||||
@@ -8,6 +8,10 @@
|
||||
|
||||
This repository wraps the latest BiRefNet model as ComfyUI nodes. Compared to the previous model, the latest model offers higher and better matting accuracy.
|
||||
|
||||
## 🔥🔥🔥 Update!!
|
||||
|
||||
* 2025/02/17: 🚀 Multiple versions of BiRefNet models are supported, such as [BiRefNet](https://huggingface.co/ZhengPeng7/BiRefNet) 、[BiRefNet_HR](https://huggingface.co/ZhengPeng7/BiRefNet_HR) 、 [BiRefNet-portrait](https://huggingface.co/ZhengPeng7/BiRefNet-portrait) .
|
||||
|
||||
## Installation
|
||||
|
||||
#### Method 1:
|
||||
|
||||
+2
-2
@@ -81,8 +81,8 @@ app.registerExtension({
|
||||
return;
|
||||
}
|
||||
|
||||
if(node.widgets_values[3] != undefined){
|
||||
localModelPathWidget.value = node.widgets_values[3];
|
||||
if(node.widgets_values[4] != undefined){
|
||||
localModelPathWidget.value = node.widgets_values[4];
|
||||
}
|
||||
|
||||
// 初始状态控制:根据 load_local_model 的值决定是否显示 local_model_path
|
||||
|
||||
@@ -65,6 +65,7 @@ class BiRefNet_Hugo:
|
||||
return {
|
||||
"required": {
|
||||
"image": ("IMAGE",),
|
||||
"model": (["ZhengPeng7/BiRefNet", "ZhengPeng7/BiRefNet_HR", "ZhengPeng7/BiRefNet-portrait"],{"default": "ZhengPeng7/BiRefNet"}),
|
||||
"load_local_model": ("BOOLEAN", {"default": False}),
|
||||
"background_color_name": (colors,{"default": "transparency"}),
|
||||
"device": (["auto", "cuda", "cpu", "mps", "xpu", "meta"],{"default": "auto"})
|
||||
@@ -81,6 +82,7 @@ class BiRefNet_Hugo:
|
||||
|
||||
def background_remove(self,
|
||||
image,
|
||||
model,
|
||||
load_local_model,
|
||||
device,
|
||||
background_color_name,
|
||||
@@ -96,7 +98,7 @@ class BiRefNet_Hugo:
|
||||
birefnet = AutoModelForImageSegmentation.from_pretrained(local_model_path,trust_remote_code=True)
|
||||
else:
|
||||
birefnet = AutoModelForImageSegmentation.from_pretrained(
|
||||
"ZhengPeng7/BiRefNet", trust_remote_code=True
|
||||
model, trust_remote_code=True
|
||||
)
|
||||
|
||||
birefnet.to(device)
|
||||
|
||||
Reference in New Issue
Block a user