Update hugging_face.yaml
Browse files- hugging_face.yaml +37 -127
hugging_face.yaml
CHANGED
|
@@ -1,45 +1,40 @@
|
|
| 1 |
_id: hugging_face
|
| 2 |
-
|
| 3 |
description: ""
|
| 4 |
-
version: 1
|
| 5 |
readme: ""
|
|
|
|
| 6 |
url: https://huggingface.co/PiperMy/Node-Packages/resolve/main/hugging_face.yaml
|
| 7 |
-
|
| 8 |
nodes:
|
| 9 |
pulid_flux:
|
| 10 |
_id: pulid_flux
|
| 11 |
arrange:
|
| 12 |
-
x:
|
| 13 |
-
y:
|
| 14 |
category:
|
|
|
|
| 15 |
id: deep_swap
|
| 16 |
-
title: en=
|
| 17 |
environment:
|
| 18 |
HF_TOKEN:
|
| 19 |
title: Hugging Face Token
|
| 20 |
type: string
|
| 21 |
scope: global
|
| 22 |
inputs:
|
| 23 |
-
|
| 24 |
order: 1
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
title: en=Prompt;ru=Подсказка
|
| 26 |
type: string
|
| 27 |
required: true
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
title: en=Person;ru=Фото человека
|
| 31 |
-
type: image
|
| 32 |
-
required: true
|
| 33 |
-
imageSize:
|
| 34 |
-
title: Image size
|
| 35 |
-
type: string
|
| 36 |
-
default: 1024x1024
|
| 37 |
-
enum:
|
| 38 |
-
- 512x512
|
| 39 |
-
- 1024x1024
|
| 40 |
outputs:
|
| 41 |
-
|
| 42 |
-
title:
|
| 43 |
type: image
|
| 44 |
package: hugging_face
|
| 45 |
script: |-
|
|
@@ -48,132 +43,47 @@ nodes:
|
|
| 48 |
const { FatalError, NextNode } = DEFINITIONS;
|
| 49 |
|
| 50 |
const HF_TOKEN = env?.variables?.get('HF_TOKEN');
|
| 51 |
-
if(!HF_TOKEN) {
|
| 52 |
throw new FatalError('Please, set your API key Hugging Face');
|
| 53 |
}
|
| 54 |
|
| 55 |
const { Client } = await import("@gradio/client/dist/index.js");
|
| 56 |
-
|
| 57 |
-
const
|
| 58 |
-
const [width, height] = imageSize.split('x');
|
| 59 |
-
return [parseInt(width), parseInt(height)];
|
| 60 |
-
})();
|
| 61 |
-
|
| 62 |
const { data: id_image } = await download(person);
|
| 63 |
-
const client = await Client.connect("PiperMy/
|
| 64 |
hf_token: HF_TOKEN
|
| 65 |
});
|
| 66 |
|
| 67 |
console.log('Send request');
|
| 68 |
try {
|
| 69 |
const { data } = await client.predict("/generate_image", {
|
| 70 |
-
prompt,
|
| 71 |
id_image,
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
id_weight: 1,
|
| 80 |
-
neg_prompt: "artefacts, bad face",
|
| 81 |
timestep_to_start_cfg: 0,
|
| 82 |
max_sequence_length: 128,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
});
|
| 84 |
const [{ url }] = data;
|
| 85 |
-
const { data:
|
| 86 |
-
return NextNode.from({ outputs: {
|
| 87 |
} catch (e) {
|
| 88 |
throw new FatalError(e.message);
|
| 89 |
}
|
| 90 |
|
| 91 |
}
|
| 92 |
source: catalog
|
| 93 |
-
title:
|
| 94 |
-
version: 1
|
| 95 |
-
deepseek_r1_8b_six:
|
| 96 |
-
_id: deepseek_r1_8b_six
|
| 97 |
-
arrange:
|
| 98 |
-
x: 210
|
| 99 |
-
y: 310
|
| 100 |
-
category:
|
| 101 |
-
id: llm_agents
|
| 102 |
-
title: en=Language Agents;ru=Языковые агенты
|
| 103 |
-
environment:
|
| 104 |
-
HF_TOKEN:
|
| 105 |
-
title: Hugging Face Token
|
| 106 |
-
type: string
|
| 107 |
-
scope: pipeline
|
| 108 |
-
inputs:
|
| 109 |
-
question:
|
| 110 |
-
order: 1
|
| 111 |
-
title: en=Question;ru=Вопрос
|
| 112 |
-
type: string
|
| 113 |
-
required: true
|
| 114 |
-
multiline: true
|
| 115 |
-
default: What time is it now? Only JSON ready to parse.
|
| 116 |
-
answerFormat:
|
| 117 |
-
order: 2
|
| 118 |
-
title: en=Answer format;ru=Формат ответа
|
| 119 |
-
description: Don't forget add instructions for LLM
|
| 120 |
-
type: string
|
| 121 |
-
required: true
|
| 122 |
-
default: text
|
| 123 |
-
enum:
|
| 124 |
-
- text|Text
|
| 125 |
-
- json|JSON
|
| 126 |
-
outputs:
|
| 127 |
-
answer:
|
| 128 |
-
title: en=Answer;ru=Ответ
|
| 129 |
-
type: string
|
| 130 |
-
json:
|
| 131 |
-
title: JSON
|
| 132 |
-
type: json
|
| 133 |
-
package: hugging_face
|
| 134 |
-
script: |
|
| 135 |
-
export async function run({ inputs }) {
|
| 136 |
-
|
| 137 |
-
const { FatalError, NextNode } = DEFINITIONS;
|
| 138 |
-
const OpenAI = require('openai');
|
| 139 |
-
|
| 140 |
-
const HF_TOKEN = env?.variables?.get('HF_TOKEN');
|
| 141 |
-
if (!HF_TOKEN) {
|
| 142 |
-
throw new FatalError('Please, set your API key for HF');
|
| 143 |
-
}
|
| 144 |
-
|
| 145 |
-
const { question, model, answerFormat } = inputs;
|
| 146 |
-
|
| 147 |
-
const openai = new OpenAI({
|
| 148 |
-
baseURL: 'https://jq20v0lfcxycc1z3.us-east-1.aws.endpoints.huggingface.cloud/v1/',
|
| 149 |
-
apiKey: HF_TOKEN,
|
| 150 |
-
});
|
| 151 |
-
|
| 152 |
-
const result = await openai.chat.completions.create({
|
| 153 |
-
model: 'lmstudio-community/DeepSeek-R1-Distill-Llama-8B-GGUF',
|
| 154 |
-
messages: [
|
| 155 |
-
{ "role": "user", "content": question },
|
| 156 |
-
],
|
| 157 |
-
});
|
| 158 |
-
|
| 159 |
-
const { content: answer } = result.choices[0].message;
|
| 160 |
-
|
| 161 |
-
switch (answerFormat) {
|
| 162 |
-
case 'text':
|
| 163 |
-
return NextNode.from({ outputs: { answer } });
|
| 164 |
-
case 'json':
|
| 165 |
-
try {
|
| 166 |
-
const json = answer.replace(/^\`\`\`json\s*/ig, '').replace(/\`\`\`\s*$/ig, '');
|
| 167 |
-
return NextNode.from({ outputs: { json: JSON.parse(json) } });
|
| 168 |
-
} catch (e) {
|
| 169 |
-
console.log(e);
|
| 170 |
-
message(`Wrong JSON for question \`\`\`text\n${question}\n\`\`\`\nnanswer from LLM\n\`\`\`text${answer}\n\`\`\``, 'defect');
|
| 171 |
-
throw new FatalError("Can't parse JSON asnwer from LLM");
|
| 172 |
-
}
|
| 173 |
-
default:
|
| 174 |
-
throw new FatalError(`Wrong answer format ${answerFormat}`);
|
| 175 |
-
}
|
| 176 |
-
}
|
| 177 |
-
source: catalog
|
| 178 |
-
title: DeepSeek R1 Distill Llama 8B Q8
|
| 179 |
version: 1
|
|
|
|
| 1 |
_id: hugging_face
|
| 2 |
+
author: Anton Breslavskii | https://github.com/breslavsky
|
| 3 |
description: ""
|
|
|
|
| 4 |
readme: ""
|
| 5 |
+
title: Hugging Face
|
| 6 |
url: https://huggingface.co/PiperMy/Node-Packages/resolve/main/hugging_face.yaml
|
| 7 |
+
version: 2
|
| 8 |
nodes:
|
| 9 |
pulid_flux:
|
| 10 |
_id: pulid_flux
|
| 11 |
arrange:
|
| 12 |
+
x: 180
|
| 13 |
+
y: 260
|
| 14 |
category:
|
| 15 |
+
_id: deep_swap
|
| 16 |
id: deep_swap
|
| 17 |
+
title: en=Magic portrait;ru=Магический портрет
|
| 18 |
environment:
|
| 19 |
HF_TOKEN:
|
| 20 |
title: Hugging Face Token
|
| 21 |
type: string
|
| 22 |
scope: global
|
| 23 |
inputs:
|
| 24 |
+
person:
|
| 25 |
order: 1
|
| 26 |
+
title: en=Person;ru=Персона
|
| 27 |
+
type: image
|
| 28 |
+
prompt:
|
| 29 |
+
order: 2
|
| 30 |
title: en=Prompt;ru=Подсказка
|
| 31 |
type: string
|
| 32 |
required: true
|
| 33 |
+
multiline: true
|
| 34 |
+
default: a portrait of a zombie
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
outputs:
|
| 36 |
+
portrait:
|
| 37 |
+
title: Portrait
|
| 38 |
type: image
|
| 39 |
package: hugging_face
|
| 40 |
script: |-
|
|
|
|
| 43 |
const { FatalError, NextNode } = DEFINITIONS;
|
| 44 |
|
| 45 |
const HF_TOKEN = env?.variables?.get('HF_TOKEN');
|
| 46 |
+
if (!HF_TOKEN) {
|
| 47 |
throw new FatalError('Please, set your API key Hugging Face');
|
| 48 |
}
|
| 49 |
|
| 50 |
const { Client } = await import("@gradio/client/dist/index.js");
|
| 51 |
+
|
| 52 |
+
const { person, prompt } = inputs;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
const { data: id_image } = await download(person);
|
| 54 |
+
const client = await Client.connect("PiperMy/tight-inversion-pulid-demo", {
|
| 55 |
hf_token: HF_TOKEN
|
| 56 |
});
|
| 57 |
|
| 58 |
console.log('Send request');
|
| 59 |
try {
|
| 60 |
const { data } = await client.predict("/generate_image", {
|
| 61 |
+
prompt: prompt || 'a portrait of a zombie',
|
| 62 |
id_image,
|
| 63 |
+
id_weight: 0.5,
|
| 64 |
+
num_steps: 16,
|
| 65 |
+
guidance: 3.5,
|
| 66 |
+
width: 1024,
|
| 67 |
+
height: 1024,
|
| 68 |
+
neg_prompt: "bad image",
|
| 69 |
+
true_cfg: 5,
|
|
|
|
|
|
|
| 70 |
timestep_to_start_cfg: 0,
|
| 71 |
max_sequence_length: 128,
|
| 72 |
+
start_step: 0,
|
| 73 |
+
seed: -1,
|
| 74 |
+
gamma: .5,
|
| 75 |
+
eta: 0.7,
|
| 76 |
+
s: 0,
|
| 77 |
+
tau: 2,
|
| 78 |
});
|
| 79 |
const [{ url }] = data;
|
| 80 |
+
const { data: portrait } = await download(url);
|
| 81 |
+
return NextNode.from({ outputs: { portrait } });
|
| 82 |
} catch (e) {
|
| 83 |
throw new FatalError(e.message);
|
| 84 |
}
|
| 85 |
|
| 86 |
}
|
| 87 |
source: catalog
|
| 88 |
+
title: Magic portrait
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
version: 1
|