Gourieff / comfyui-reactor-node

Fast and Simple Face Swap Extension Node for ComfyUI
GNU General Public License v3.0
1.47k stars 142 forks source link

[Feature]: A way to load face models from arbitrary path #305

Open Mozoloa opened 4 months ago

Mozoloa commented 4 months ago

Feature description

I think it would be cool to not be limited to the reactor/faces folder, without having to add new paths to the yaml (I don't even think the current code fetches alternative paths there anyway). Like I want to have my facemodel next to the input pics (that I use for Ipadapter before reactor) in dedicated folders for each person, as to load it all seamlessly with a single path.

It would be great if just entering a full path instead of selecting a name from the preloaded models, would fetch the model in that path. Or maybe have a Load Face Model (Path) Reactor node ?

Mozoloa commented 4 months ago

Here's a quick suggestion that works: adding a new node by creating this class in nodes.py, then mapping it at the end in NODE_CLASS_MAPPING and NODE_DISPLAY_NAME_MAPPINGS

class LoadFaceModelFromPath:
    @classmethod
    def INPUT_TYPES(s):
        return {
            "required": {
                "face_model_path": ("STRING", {"default": "none"}),
            }
        }

    RETURN_TYPES = ("FACE_MODEL",)
    FUNCTION = "load_model_from_path"
    CATEGORY = "🌌 ReActor"

    def load_model_from_path(self, face_model_path):
        self.face_model_path = face_model_path
        if self.face_model_path != "none":
            out = load_face_model(self.face_model_path)
        else:
            out = None
        return (out,)

I've never dev'd comfy nodes so this may be suboptimal, it could also be cleaner to add an option to the existing node. I'm not doing a PR as i'm not sure which formatting tool you use and mine changes way too much to make the pr readable lmao