| _id: hugging_face | |
| author: Anton Breslavskii | https://github.com/breslavsky | |
| description: "" | |
| readme: "" | |
| title: Hugging Face | |
| url: https://huggingface.co/PiperMy/Node-Packages/resolve/main/hugging_face.yaml | |
| version: 2 | |
| nodes: | |
| pulid_flux: | |
| _id: pulid_flux | |
| arrange: | |
| x: 180 | |
| y: 260 | |
| category: | |
| _id: deep_swap | |
| title: en=Magic portrait;ru=Магический портрет | |
| environment: | |
| HF_TOKEN: | |
| title: Hugging Face Token | |
| type: string | |
| scope: global | |
| inputs: | |
| person: | |
| order: 1 | |
| title: en=Person;ru=Персона | |
| type: image | |
| prompt: | |
| order: 2 | |
| title: en=Prompt;ru=Подсказка | |
| type: string | |
| required: true | |
| multiline: true | |
| default: a portrait of a zombie | |
| outputs: | |
| portrait: | |
| title: Portrait | |
| type: image | |
| package: hugging_face | |
| script: |- | |
| export async function run({ inputs }) { | |
| const { FatalError, NextNode } = DEFINITIONS; | |
| const HF_TOKEN = env?.variables?.get('HF_TOKEN'); | |
| if (!HF_TOKEN) { | |
| throw new FatalError('Please, set your API key Hugging Face'); | |
| } | |
| const { Client } = await import("@gradio/client/dist/index.js"); | |
| const { person, prompt } = inputs; | |
| const { data: id_image } = await download(person); | |
| const client = await Client.connect("PiperMy/tight-inversion-pulid-demo", { | |
| hf_token: HF_TOKEN | |
| }); | |
| console.log('Send request'); | |
| try { | |
| const { data } = await client.predict("/generate_image", { | |
| prompt: prompt || 'a portrait of a zombie', | |
| id_image, | |
| id_weight: 0.5, | |
| num_steps: 16, | |
| guidance: 3.5, | |
| width: 1024, | |
| height: 1024, | |
| neg_prompt: "bad image", | |
| true_cfg: 5, | |
| timestep_to_start_cfg: 0, | |
| max_sequence_length: 128, | |
| start_step: 0, | |
| seed: -1, | |
| gamma: .5, | |
| eta: 0.7, | |
| s: 0, | |
| tau: 2, | |
| }); | |
| const [{ url }] = data; | |
| const { data: portrait } = await download(url); | |
| return NextNode.from({ outputs: { portrait } }); | |
| } catch (e) { | |
| throw new FatalError(e.message); | |
| } | |
| } | |
| source: catalog | |
| title: Magic portrait | |
| version: 1 | |