mirror of
https://github.com/storytold/storyteller-ml.git
synced 2026-10-18 07:41:03 +00:00
remove old comfyUI
This commit is contained in:
@@ -1,21 +0,0 @@
|
||||
# [Rembg](https://github.com/danielgatis/rembg) Background Removal Node for [ComfyUI](https://github.com/comfyanonymous/ComfyUI)
|
||||
1. Clone to your `custom_nodes` folder in ComfyUI:
|
||||
|
||||
```
|
||||
git clone https://github.com/Jcd1230/rembg-comfyui-node.git
|
||||
```
|
||||
|
||||
2. Install `rembg[gpu]` (recommended) or `rembg`, depending on GPU support, to your ComfyUI virtual environment. E.g.:
|
||||
|
||||
```
|
||||
pip install rembg[gpu]
|
||||
```
|
||||
|
||||
|
||||
To use, just look for the *Image Remove Background (rembg)* node.
|
||||
|
||||

|
||||
|
||||
|
||||
## Acknowledgements
|
||||
Thanks to [WASasquatch's Node Suite](https://github.com/WASasquatch/was-node-suite-comfyui) for great examples and a couple helper functions.
|
||||
@@ -1,39 +0,0 @@
|
||||
from rembg import remove
|
||||
from PIL import Image
|
||||
import torch
|
||||
import numpy as np
|
||||
|
||||
# Tensor to PIL
|
||||
def tensor2pil(image):
|
||||
return Image.fromarray(np.clip(255. * image.cpu().numpy().squeeze(), 0, 255).astype(np.uint8))
|
||||
|
||||
# Convert PIL to Tensor
|
||||
def pil2tensor(image):
|
||||
return torch.from_numpy(np.array(image).astype(np.float32) / 255.0).unsqueeze(0)
|
||||
|
||||
class ImageRemoveBackgroundRembg:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def INPUT_TYPES(s):
|
||||
return {
|
||||
"required": {
|
||||
"image": ("IMAGE",),
|
||||
},
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("IMAGE",)
|
||||
FUNCTION = "remove_background"
|
||||
CATEGORY = "image"
|
||||
|
||||
def remove_background(self, image):
|
||||
image = pil2tensor(remove(tensor2pil(image)))
|
||||
return (image,)
|
||||
|
||||
|
||||
# A dictionary that contains all nodes you want to export with their names
|
||||
# NOTE: names should be globally unique
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"Image Remove Background (rembg)": ImageRemoveBackgroundRembg
|
||||
}
|
||||
BIN
Binary file not shown.
@@ -1 +0,0 @@
|
||||
rembg
|
||||
Reference in New Issue
Block a user