Skip to content

Commit 361f7f4

Browse files
committed
First commit
1 parent 2255ffe commit 361f7f4

File tree

7 files changed

+242
-21
lines changed

7 files changed

+242
-21
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Publish to Comfy registry
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- "pyproject.toml"
9+
10+
jobs:
11+
publish-node:
12+
name: Publish Custom Node to registry
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Check out code
16+
uses: actions/checkout@v4
17+
- name: Publish Custom Node
18+
uses: Comfy-Org/publish-node-action@main
19+
with:
20+
personal_access_token: ${{ secrets.REGISTRY_ACCESS_TOKEN }} ## Add your own personal access token to your Github Repository secrets and reference it here.

InfiniteYouSampler.py

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
import os
2+
import comfy
3+
import torch
4+
import torchvision
5+
import sys
6+
import folder_paths
7+
import numpy
8+
import pygit2
9+
from PIL import Image, ImageOps
10+
11+
this_path = os.path.dirname(__file__)
12+
repo_dir = os.path.join(this_path,"InfiniteYou")
13+
requirements_txt = os.path.join(repo_dir,"requirements.txt")
14+
15+
if not os.path.exists(requirements_txt):
16+
pygit2.clone_repository("https://github.com/bytedance/InfiniteYou", repo_dir, depth=1)
17+
if not os.path.exists(requirements_txt):
18+
print("*** Could not get InfiniteYou repository. Please install git.")
19+
20+
sys.path.insert(0, this_path)
21+
from InfiniteYou.pipelines.pipeline_infu_flux import InfUFluxPipeline
22+
sys.path.remove(this_path)
23+
24+
class InfiniteYouSampler:
25+
def __init__(self):
26+
pass
27+
28+
@classmethod
29+
def INPUT_TYPES(s):
30+
return {
31+
"required": {
32+
"id_image": ("IMAGE",),
33+
"base_model": (['auto'] + folder_paths.get_filename_list("diffusion_models"),),
34+
"seed": ("INT", {
35+
}),
36+
"prompt": ("STRING", {
37+
"multiline": True,
38+
"default": "a robot",
39+
"lazy": True
40+
}),
41+
"steps": ("INT", {
42+
"default": 30
43+
}),
44+
},
45+
"optional": {
46+
"guidance": ("FLOAT", {
47+
"default": 3.5,
48+
"min": 0.0,
49+
"step": 0.1,
50+
"round": 0.01,
51+
"display": "number",
52+
"lazy": True
53+
}),
54+
"infusenet_conditioning_scale": ("FLOAT", {
55+
"default": 1.0,
56+
"min": 0.0,
57+
"step": 0.1,
58+
"round": 0.01,
59+
"display": "number",
60+
"lazy": True
61+
}),
62+
"infusenet_guidance_start": ("FLOAT", {
63+
"default": 0.0,
64+
"min": 0.0,
65+
"step": 0.1,
66+
"round": 0.01,
67+
"display": "number",
68+
"lazy": True
69+
}),
70+
"infusenet_guidance_end": ("FLOAT", {
71+
"default": 1.0,
72+
"min": 0.0,
73+
"step": 0.1,
74+
"round": 0.01,
75+
"display": "number",
76+
"lazy": True
77+
}),
78+
"model_version": (['aes_stage2', 'sim_stage1'], {
79+
"default": 'aes_stage2'
80+
}),
81+
"control_image": ("IMAGE",),
82+
},
83+
}
84+
85+
RETURN_TYPES = ("IMAGE",)
86+
87+
FUNCTION = "sampler"
88+
CATEGORY = "sampling"
89+
90+
def sampler(
91+
self,
92+
id_image,
93+
base_model, # TODO
94+
seed,
95+
prompt,
96+
steps=30,
97+
guidance=3.5,
98+
infusenet_conditioning_scale=1.0,
99+
infusenet_guidance_start=0.0,
100+
infusenet_guidance_end=1.0,
101+
model_version='aes_stage2',
102+
control_image=None,
103+
):
104+
torch.cuda.set_device(comfy.model_management.get_torch_device())
105+
106+
infu_flux_version = 'v1.0'
107+
model_dir = 'ByteDance/InfiniteYou'
108+
if base_model == 'auto':
109+
base_model_path = 'black-forest-labs/FLUX.1-dev'
110+
else:
111+
base_model_path = folder_paths.get_full_path_or_raise("diffusion_models", base_model)
112+
113+
infu_model_path = os.path.join(
114+
model_dir, f'infu_flux_{infu_flux_version}',
115+
model_version
116+
)
117+
insightface_root_path = os.path.join(
118+
model_dir, 'supports', 'insightface'
119+
)
120+
pipe = InfUFluxPipeline(
121+
base_model_path=base_model_path,
122+
infu_model_path=infu_model_path,
123+
insightface_root_path=insightface_root_path,
124+
infu_flux_version=infu_flux_version,
125+
model_version=model_version,
126+
)
127+
128+
control_image_pil = None
129+
if control_image is not None:
130+
control_i = 255. * control_image[0].cpu().numpy()
131+
control_image_pil = Image.fromarray(numpy.clip(i, 0, 255).astype(numpy.uint8))
132+
i = 255. * id_image[0].cpu().numpy()
133+
img = Image.fromarray(numpy.clip(i, 0, 255).astype(numpy.uint8))
134+
image = pipe(
135+
id_image=img,
136+
prompt=prompt,
137+
control_image=control_image_pil,
138+
seed=seed,
139+
guidance_scale=guidance,
140+
num_steps=steps,
141+
infusenet_conditioning_scale=infusenet_conditioning_scale,
142+
infusenet_guidance_start=infusenet_guidance_start,
143+
infusenet_guidance_end=infusenet_guidance_end,
144+
)
145+
146+
image = image.convert("RGB")
147+
image = numpy.array(image).astype(numpy.float32) / 255.0
148+
image = torch.from_numpy(image)[None,]
149+
images = []
150+
images.append(image)
151+
152+
if len(images) > 1:
153+
images = torch.cat(images, dim=0)
154+
else:
155+
images = images[0]
156+
157+
return (images,)

LICENSE

Lines changed: 0 additions & 21 deletions
This file was deleted.

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Put anyone's face on anything with Byte Dance's [InfiniteYou](https://github.com/bytedance/InfiniteYou).
3+
4+
## Hardware
5+
6+
Uses 40GB of VRAM. Takes about a minute on an RTX A6000, 48GB.
7+
8+
Note: I only had temporary access to the hardware to run this. Might not be able to help much.
9+
10+
11+
## Installation
12+
13+
To get FLUX, you need to run `huggingface-cli login`.
14+
And put in your huggingface access token from [https://huggingface.co/settings/tokens](https://huggingface.co/settings/tokens)
15+
16+
At the moment it needs `diffusers==0.31` `numpy<2`. If something goes wrong make sure these versions are installed `pip show numpy diffusers`
17+
18+
19+
## runpod
20+
21+
Link the ~/.cache folder to permanent storage or else it'll get wiped every time and it'll redownload the models every time.
22+

__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
from .InfiniteYouSampler import InfiniteYouSampler
3+
4+
5+
NODE_CLASS_MAPPINGS = {
6+
"InfiniteYouSampler": InfiniteYouSampler
7+
}
8+
9+
# A dictionary that contains the friendly/humanly readable titles for the nodes
10+
NODE_DISPLAY_NAME_MAPPINGS = {
11+
"InfiniteYouSampler": "InfiniteYou Sampler"
12+
}

pyproject.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# pyproject.toml
2+
[project]
3+
name = "ComfyUI-InifiniteYou" # Unique identifier for your node. Immutable after creation.
4+
description = "ComfyUI custom_node for ByteDance's InfiniteYou"
5+
version = "1.0.0" # Custom Node version. Must be semantically versioned.
6+
license = {text = "MIT License"}
7+
8+
[project.urls]
9+
Repository = "https://github.com/niknah/ComfyUI-InfiniteYou"
10+
11+
[tool.comfy]
12+
PublisherId = "niknah"
13+
DisplayName = "ComfyUI-InfiniteYou" # Display name for the Custom Node. Can be changed later.

requirements.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
accelerate
2+
diffusers==0.31
3+
facexlib
4+
huggingface-hub
5+
insightface
6+
numpy
7+
numpy==1.26.4
8+
onnxruntime
9+
opencv-python
10+
pillow
11+
pillow-avif-plugin
12+
pillow-heif
13+
sentencepiece
14+
torch
15+
torchvision
16+
transformers
17+
peft
18+
pygit2

0 commit comments

Comments
 (0)