Update artworks.yaml
Browse files- artworks.yaml +1561 -761
artworks.yaml
CHANGED
|
@@ -5,13 +5,1298 @@ title: en=ArtWorks AI;ru=Узлы ArtWorks AI
|
|
| 5 |
url: https://huggingface.co/PiperMy/Node-Packages/resolve/main/artworks.yaml
|
| 6 |
version: 2
|
| 7 |
nodes:
|
| 8 |
-
|
| 9 |
-
_id:
|
| 10 |
arrange:
|
| 11 |
-
x:
|
| 12 |
-
y:
|
| 13 |
category:
|
| 14 |
-
id:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
title: en=Image analysis;ru=Анализ изображений
|
| 16 |
environment:
|
| 17 |
OPEN_PAAS_USER:
|
|
@@ -32,155 +1317,147 @@ nodes:
|
|
| 32 |
title: en=Image;ru=Изображение
|
| 33 |
type: image
|
| 34 |
required: true
|
| 35 |
-
|
| 36 |
order: 2
|
| 37 |
-
title: en=
|
| 38 |
-
type:
|
| 39 |
required: true
|
| 40 |
-
default:
|
| 41 |
-
enum:
|
| 42 |
-
- isnet-general-use|IsNet
|
| 43 |
-
- u2net|U2Net
|
| 44 |
outputs:
|
| 45 |
-
|
| 46 |
-
title: en=
|
| 47 |
type: image
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
package: artworks
|
| 49 |
-
script:
|
| 50 |
-
const PAAS_BASE_URL = env.variables.get('PAAS_BASE_URL');
|
| 51 |
-
if(!PAAS_BASE_URL) {
|
| 52 |
-
error.fatal('Please, set PAAS_BASE_URL in environment');
|
| 53 |
-
}
|
| 54 |
-
const OPEN_PAAS_USER = env.variables.get('OPEN_PAAS_USER');
|
| 55 |
-
if(!OPEN_PAAS_USER) {
|
| 56 |
-
error.fatal('Please, set OPEN_PAAS_USER in environment');
|
| 57 |
-
}
|
| 58 |
-
const OPEN_PAAS_PASSWORD = env.variables.get('OPEN_PAAS_PASSWORD');
|
| 59 |
-
if(!OPEN_PAAS_PASSWORD) {
|
| 60 |
-
error.fatal('Please, set OPEN_PAAS_PASSWORD in environment');
|
| 61 |
-
}
|
| 62 |
-
const PAAS_AUTH = {
|
| 63 |
-
username: OPEN_PAAS_USER,
|
| 64 |
-
password: OPEN_PAAS_PASSWORD
|
| 65 |
-
};
|
| 66 |
const CHECK_TASK_INTERVAL = 3000;
|
|
|
|
| 67 |
|
| 68 |
-
|
| 69 |
-
return `${PAAS_BASE_URL}/api/v3/${path}`;
|
| 70 |
-
}
|
| 71 |
|
| 72 |
-
async function
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
method: "post",
|
| 76 |
-
url: getUrl("tasks"),
|
| 77 |
-
headers: {
|
| 78 |
-
"Content-type": "application/json",
|
| 79 |
-
},
|
| 80 |
-
auth: PAAS_AUTH,
|
| 81 |
-
data: JSON.stringify(payload),
|
| 82 |
-
});
|
| 83 |
-
const {
|
| 84 |
-
id
|
| 85 |
-
} = response.data;
|
| 86 |
-
return id;
|
| 87 |
-
} catch (e) {
|
| 88 |
-
const {
|
| 89 |
-
errors
|
| 90 |
-
} = e.response?.data || {};
|
| 91 |
-
if (errors?.length > 0) {
|
| 92 |
-
error.fatal(errors.join(", "));
|
| 93 |
-
}
|
| 94 |
-
error.fatal(e.statusText);
|
| 95 |
-
}
|
| 96 |
-
}
|
| 97 |
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
const {
|
| 112 |
-
errors
|
| 113 |
-
} = e.response?.data;
|
| 114 |
-
if (errors?.length > 0) {
|
| 115 |
-
error.fatal(errors.join(", "));
|
| 116 |
-
}
|
| 117 |
-
error.fatal(e.statusText);
|
| 118 |
}
|
|
|
|
|
|
|
| 119 |
}
|
| 120 |
|
| 121 |
-
async function
|
| 122 |
-
const
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
});
|
| 132 |
|
| 133 |
-
|
| 134 |
-
status,
|
| 135 |
-
results
|
| 136 |
-
} = data;
|
| 137 |
-
switch (status) {
|
| 138 |
-
case "preparing":
|
| 139 |
-
case "scheduling":
|
| 140 |
-
case "scheduled":
|
| 141 |
-
case "pending":
|
| 142 |
-
case "processing":
|
| 143 |
-
return null;
|
| 144 |
-
case "completed":
|
| 145 |
-
const {
|
| 146 |
-
data
|
| 147 |
-
} = results;
|
| 148 |
-
return data;
|
| 149 |
-
case "failed":
|
| 150 |
-
error.fatal(results.error);
|
| 151 |
-
default:
|
| 152 |
-
error.fatal("Wrong task status");
|
| 153 |
-
}
|
| 154 |
}
|
| 155 |
|
| 156 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
|
| 158 |
-
const {
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
|
|
|
| 162 |
|
| 163 |
if (!state) {
|
|
|
|
|
|
|
| 164 |
const payload = {
|
| 165 |
-
type: "
|
| 166 |
isFast: true,
|
| 167 |
payload: {
|
| 168 |
base64: false,
|
| 169 |
-
model,
|
| 170 |
image,
|
|
|
|
| 171 |
},
|
| 172 |
};
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
} else {
|
| 185 |
const {
|
| 186 |
payload,
|
|
@@ -188,53 +1465,80 @@ nodes:
|
|
| 188 |
attempt,
|
| 189 |
startedAt
|
| 190 |
} = state;
|
| 191 |
-
|
| 192 |
-
|
|
|
|
|
|
|
|
|
|
| 193 |
|
| 194 |
const now = new Date();
|
| 195 |
const time = (now - new Date(startedAt)) / 1000;
|
| 196 |
-
|
| 197 |
}
|
| 198 |
|
| 199 |
-
log(`Check task ${attempt} ${task}`);
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 209 |
},
|
| 210 |
});
|
| 211 |
-
}
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
outputs: {
|
| 215 |
-
image
|
| 216 |
}
|
| 217 |
-
|
|
|
|
| 218 |
}
|
| 219 |
-
|
| 220 |
-
})();
|
| 221 |
source: catalog
|
| 222 |
-
title: en=
|
| 223 |
version: 1
|
| 224 |
-
|
| 225 |
-
_id:
|
| 226 |
arrange:
|
| 227 |
-
x:
|
| 228 |
-
y:
|
| 229 |
category:
|
| 230 |
-
id:
|
| 231 |
-
title: en=
|
| 232 |
-
costs: |-
|
| 233 |
-
const COST_PER_IMAGE = 0.02;
|
| 234 |
-
(() => {
|
| 235 |
-
const { batchSize } = inputs;
|
| 236 |
-
return batchSize * COST_PER_IMAGE;
|
| 237 |
-
})()
|
| 238 |
environment:
|
| 239 |
OPEN_PAAS_USER:
|
| 240 |
title: PaaS user
|
|
@@ -248,607 +1552,91 @@ nodes:
|
|
| 248 |
title: PaaS base url
|
| 249 |
type: string
|
| 250 |
scope: global
|
| 251 |
-
groups:
|
| 252 |
-
inputs:
|
| 253 |
-
SDXL:
|
| 254 |
-
order: 2
|
| 255 |
-
title: SDXL checkpoints
|
| 256 |
-
description: Only for SDXL checkpoints
|
| 257 |
-
base:
|
| 258 |
-
order: 1
|
| 259 |
-
title: en=Base parameters;ru=Базовые параметры
|
| 260 |
inputs:
|
| 261 |
-
|
| 262 |
-
order: 2
|
| 263 |
-
title: Checkpoint
|
| 264 |
-
group: base
|
| 265 |
-
type: string
|
| 266 |
-
required: true
|
| 267 |
-
default: juggernautXL_v9Rundiffusionphoto2.safetensors
|
| 268 |
-
enum:
|
| 269 |
-
- raemuXL_v40.safetensors|Raemu XL <SDXL>
|
| 270 |
-
- aamXLAnimeMix_v10.safetensors|AAM XL (Anime Mix) <SDXL> <Fantasy>
|
| 271 |
-
- dreamweaverPony25D.1erv.safetensors|DreamWeaver - Pony 2.5D Mix <SDXL>
|
| 272 |
-
- mixGEMAdam8witQegoow.NeWz.safetensors|MyMIX-G/Jem <SDXL> <Realistic>
|
| 273 |
-
- mfcgPDXL_v10.safetensors|MFCG PDXL <SDXL>
|
| 274 |
-
- aniku_0.2.fp16.safetensors|Anime Desire <SDXL> <Fantasy>
|
| 275 |
-
- flux1DevHyperNF4Flux1DevBNB_flux1DevHyperNF4.safetensors|Hyper NF4 Flux 1 <Flux>
|
| 276 |
-
- STOIQONewrealityFLUXSD_F1DPreAlpha.safetensors|New Reality Flux <Flux>
|
| 277 |
-
- juggernautXL_v9Rundiffusionphoto2.safetensors|Juggernaut XL <SDXL>
|
| 278 |
-
- animaPencilXL_v260.safetensors|Anima Pencil XL <SDXL> <Fantasy>
|
| 279 |
-
- bluePencilXL_v401.safetensors|Blue Pencil XL <SDXL> <Fantasy>
|
| 280 |
-
- pixelArtDiffusionXL_spriteShaper.safetensors|Pixel Art Diffusion XL <SDXL> <Fantasy>
|
| 281 |
-
- albedobaseXL_v20.safetensors|AlbedoBase XL <SDXL>
|
| 282 |
-
- leosamsHelloworldXL_helloworldXL50GPT4V.safetensors|Helloworld XL <SDXL>
|
| 283 |
-
- dynavisionXLAllInOneStylized_releaseV0610Bakedvae.safetensors|DynaVision XL All In One <SDXL>
|
| 284 |
-
- photon_v1.safetensors|Photon <SD 1.5>
|
| 285 |
-
- afroditexlNudePeople_20Bkdvae.safetensors|Nude People <NSFW>
|
| 286 |
-
- nosft-float8-e4m3fn.safetensors|Flux Nude People <NSFW>
|
| 287 |
-
- asdf_0.4a_lorapov_0.2_lust_0.4.fp16.safetensors|Real Porn <NSFW>
|
| 288 |
-
- Sexy_Aesthetic_SDXL_0.4x0.2.fp16.safetensors|Sexy & Beauty <NSFW>
|
| 289 |
-
- aniku_0.2.fp16.safetensors|Anime Desire <NSFW>
|
| 290 |
-
- anikurender_0.4b.fp16.safetensors|Hardcore Fantasy <NSFW>
|
| 291 |
-
prompt:
|
| 292 |
order: 1
|
| 293 |
-
title:
|
| 294 |
-
|
| 295 |
-
type: string
|
| 296 |
-
required: true
|
| 297 |
-
multiline: true
|
| 298 |
-
default: cat walking on the moon
|
| 299 |
-
imageSize:
|
| 300 |
-
order: 4
|
| 301 |
-
title: Size
|
| 302 |
-
group: base
|
| 303 |
-
type: string
|
| 304 |
required: true
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
- 512x768|512x768 <SD 1.5>
|
| 309 |
-
- 512x912|512x912 <SD 1.5>
|
| 310 |
-
- 576x768|576x768 <SD 1.5>
|
| 311 |
-
- 704x1344|704x1344 <SD 1.5>
|
| 312 |
-
- 704x1408|704x1408 <SD 1.5>
|
| 313 |
-
- 768x512|768x512 <SD 1.5>
|
| 314 |
-
- 768x576|768x576 <SD 1.5>
|
| 315 |
-
- 768x768|768x768 <SD 1.5>
|
| 316 |
-
- 768x1280|768x1280 <SD 1.5>
|
| 317 |
-
- 768x1344|768x1344 <SD 1.5>
|
| 318 |
-
- 832x1152|832x1152 <SD 1.5>
|
| 319 |
-
- 832x1216|832x1216 <SD 1.5>
|
| 320 |
-
- 896x1088|896x1088 <SD 1.5>
|
| 321 |
-
- 896x1152|896x1152 <SD 1.5>
|
| 322 |
-
- 912x512|912x512 <SD 1.5>
|
| 323 |
-
- 960x1024|960x1024 <SDXL> <Flux> <SD 1.5>
|
| 324 |
-
- 960x1088|960x1088 <SDXL> <Flux> <SD 1.5>
|
| 325 |
-
- 1024x1024|1024x1024 <SDXL> <Flux> <SD 1.5>
|
| 326 |
-
- 1024x960|1024x960 <SDXL> <Flux> <SD 1.5>
|
| 327 |
-
- 1088x896|1088x896 <SDXL> <Flux> <SD 1.5>
|
| 328 |
-
- 1088x960|1088x960 <SDXL> <Flux> <SD 1.5>
|
| 329 |
-
- 1152x832|1152x832 <SDXL> <Flux> <SD 1.5>
|
| 330 |
-
- 1152x896|1152x896 <SDXL> <Flux> <SD 1.5>
|
| 331 |
-
- 1216x832|1216x832 <SDXL> <Flux>
|
| 332 |
-
- 1280x768|1280x768 <SDXL> <Flux>
|
| 333 |
-
- 1344x704|1344x704 <SDXL> <Flux>
|
| 334 |
-
- 1344x768|1344x768 <SDXL> <Flux>
|
| 335 |
-
- 1408x704|1408x704 <SDXL> <Flux>
|
| 336 |
-
- 1472x704|1472x704 <SDXL> <Flux>
|
| 337 |
-
- 1536x640|1536x640 <SDXL> <Flux>
|
| 338 |
-
- 1600x640|1600x640 <SDXL> <Flux>
|
| 339 |
-
- 1664x576|1664x576 <SDXL> <Flux>
|
| 340 |
-
- 1728x576|1728x576 <SDXL> <Flux>
|
| 341 |
-
batchSize:
|
| 342 |
-
order: 7
|
| 343 |
-
title: Batch size
|
| 344 |
-
group: base
|
| 345 |
-
type: integer
|
| 346 |
-
min: 1
|
| 347 |
-
max: 4
|
| 348 |
-
step: 1
|
| 349 |
-
default: 1
|
| 350 |
-
negativePrompt:
|
| 351 |
-
order: 3
|
| 352 |
-
title: Negative prompt
|
| 353 |
-
group: base
|
| 354 |
type: string
|
| 355 |
-
multiline: true
|
| 356 |
-
cfgScale:
|
| 357 |
-
order: 5
|
| 358 |
-
title: CFG scale
|
| 359 |
-
group: base
|
| 360 |
-
type: float
|
| 361 |
required: true
|
| 362 |
-
|
| 363 |
-
max: 20
|
| 364 |
-
step: 1
|
| 365 |
-
default: 7
|
| 366 |
-
performance:
|
| 367 |
-
order: 6
|
| 368 |
-
title: Performance
|
| 369 |
-
group: base
|
| 370 |
-
type: string
|
| 371 |
-
default: speed
|
| 372 |
-
enum:
|
| 373 |
-
- express|⚡ Express
|
| 374 |
-
- speed|🚅 Speed
|
| 375 |
-
- quality|💎 Quality
|
| 376 |
-
styles:
|
| 377 |
-
order: 2
|
| 378 |
-
title: Styles
|
| 379 |
-
group: SDXL
|
| 380 |
-
type: string[]
|
| 381 |
enum:
|
| 382 |
-
-
|
| 383 |
-
-
|
| 384 |
-
- Action Figure
|
| 385 |
-
- Adorable 3D Character
|
| 386 |
-
- Adorable Kawaii
|
| 387 |
-
- Ads Advertising
|
| 388 |
-
- Ads Automotive
|
| 389 |
-
- Ads Corporate
|
| 390 |
-
- Ads Fashion Editorial
|
| 391 |
-
- Ads Food Photography
|
| 392 |
-
- Ads Gourmet Food Photography
|
| 393 |
-
- Ads Luxury
|
| 394 |
-
- Ads Real Estate
|
| 395 |
-
- Ads Retail
|
| 396 |
-
- Art Deco
|
| 397 |
-
- Art Nouveau
|
| 398 |
-
- Artstyle Abstract
|
| 399 |
-
- Artstyle Abstract Expressionism
|
| 400 |
-
- Artstyle Art Deco
|
| 401 |
-
- Artstyle Art Nouveau
|
| 402 |
-
- Artstyle Constructivist
|
| 403 |
-
- Artstyle Cubist
|
| 404 |
-
- Artstyle Expressionist
|
| 405 |
-
- Artstyle Graffiti
|
| 406 |
-
- Artstyle Hyperrealism
|
| 407 |
-
- Artstyle Impressionist
|
| 408 |
-
- Artstyle Pointillism
|
| 409 |
-
- Artstyle Pop Art
|
| 410 |
-
- Artstyle Psychedelic
|
| 411 |
-
- Artstyle Renaissance
|
| 412 |
-
- Artstyle Steampunk
|
| 413 |
-
- Artstyle Surrealist
|
| 414 |
-
- Artstyle Typography
|
| 415 |
-
- Artstyle Watercolor
|
| 416 |
-
- Astral Aura
|
| 417 |
-
- Avant Garde
|
| 418 |
-
- Baroque
|
| 419 |
-
- Bauhaus Style Poster
|
| 420 |
-
- Blueprint Schematic Drawing
|
| 421 |
-
- Caricature
|
| 422 |
-
- Cel Shaded Art
|
| 423 |
-
- Character Design Sheet
|
| 424 |
-
- Cinematic Diva
|
| 425 |
-
- Classicism Art
|
| 426 |
-
- Color Field Painting
|
| 427 |
-
- Colored Pencil Art
|
| 428 |
-
- Conceptual Art
|
| 429 |
-
- Constructivism
|
| 430 |
-
- Cubism
|
| 431 |
-
- Dadaism
|
| 432 |
-
- Dark Fantasy
|
| 433 |
-
- Dark Moody Atmosphere
|
| 434 |
-
- Dmt Art Style
|
| 435 |
-
- Doodle Art
|
| 436 |
-
- Double Exposure
|
| 437 |
-
- Dripping Paint Splatter Art
|
| 438 |
-
- Expressionism
|
| 439 |
-
- Faded Polaroid Photo
|
| 440 |
-
- Fauvism
|
| 441 |
-
- Flat 2d Art
|
| 442 |
-
- Fooocus Cinematic
|
| 443 |
-
- Fooocus Enhance
|
| 444 |
-
- Fooocus Masterpiece
|
| 445 |
-
- Fooocus Negative
|
| 446 |
-
- Fooocus Photograph
|
| 447 |
-
- Fooocus Semi Realistic
|
| 448 |
-
- Fooocus Sharp
|
| 449 |
-
- Fooocus V2
|
| 450 |
-
- Fortnite Art Style
|
| 451 |
-
- Futurism
|
| 452 |
-
- Futuristic Biomechanical
|
| 453 |
-
- Futuristic Biomechanical Cyberpunk
|
| 454 |
-
- Futuristic Cybernetic
|
| 455 |
-
- Futuristic Cybernetic Robot
|
| 456 |
-
- Futuristic Cyberpunk Cityscape
|
| 457 |
-
- Futuristic Futuristic
|
| 458 |
-
- Futuristic Retro Cyberpunk
|
| 459 |
-
- Futuristic Retro Futurism
|
| 460 |
-
- Futuristic Sci Fi
|
| 461 |
-
- Futuristic Vaporwave
|
| 462 |
-
- Game Bubble Bobble
|
| 463 |
-
- Game Cyberpunk Game
|
| 464 |
-
- Game Fighting Game
|
| 465 |
-
- Game Gta
|
| 466 |
-
- Game Mario
|
| 467 |
-
- Game Minecraft
|
| 468 |
-
- Game Pokemon
|
| 469 |
-
- Game Retro Arcade
|
| 470 |
-
- Game Retro Game
|
| 471 |
-
- Game Rpg Fantasy Game
|
| 472 |
-
- Game Strategy Game
|
| 473 |
-
- Game Streetfighter
|
| 474 |
-
- Game Zelda
|
| 475 |
-
- Glitchcore
|
| 476 |
-
- Glo Fi
|
| 477 |
-
- Googie Art Style
|
| 478 |
-
- Graffiti Art
|
| 479 |
-
- Harlem Renaissance Art
|
| 480 |
-
- High Fashion
|
| 481 |
-
- Idyllic
|
| 482 |
-
- Impressionism
|
| 483 |
-
- Infographic Drawing
|
| 484 |
-
- Ink Dripping Drawing
|
| 485 |
-
- Japanese Ink Drawing
|
| 486 |
-
- Knolling Photography
|
| 487 |
-
- Light Cheery Atmosphere
|
| 488 |
-
- Logo Design
|
| 489 |
-
- Luxurious Elegance
|
| 490 |
-
- MRE Ancient Illustration
|
| 491 |
-
- MRE Anime
|
| 492 |
-
- MRE Artistic Vision
|
| 493 |
-
- MRE Bad Dream
|
| 494 |
-
- MRE Brave Art
|
| 495 |
-
- MRE Cinematic Dynamic
|
| 496 |
-
- MRE Comic
|
| 497 |
-
- MRE Dark Cyberpunk
|
| 498 |
-
- MRE Dark Dream
|
| 499 |
-
- MRE Dynamic Illustration
|
| 500 |
-
- MRE Elemental Art
|
| 501 |
-
- MRE Gloomy Art
|
| 502 |
-
- MRE Heroic Fantasy
|
| 503 |
-
- MRE Lyrical Geometry
|
| 504 |
-
- MRE Manga
|
| 505 |
-
- MRE Space Art
|
| 506 |
-
- MRE Spontaneous Picture
|
| 507 |
-
- MRE Sumi E Detailed
|
| 508 |
-
- MRE Sumi E Symbolic
|
| 509 |
-
- MRE Surreal Painting
|
| 510 |
-
- MRE Undead Art
|
| 511 |
-
- MRE Underground
|
| 512 |
-
- Macro Photography
|
| 513 |
-
- Mandola Art
|
| 514 |
-
- Marker Drawing
|
| 515 |
-
- Medievalism
|
| 516 |
-
- Minimalism
|
| 517 |
-
- Misc Architectural
|
| 518 |
-
- Misc Disco
|
| 519 |
-
- Misc Dreamscape
|
| 520 |
-
- Misc Dystopian
|
| 521 |
-
- Misc Fairy Tale
|
| 522 |
-
- Misc Gothic
|
| 523 |
-
- Misc Grunge
|
| 524 |
-
- Misc Horror
|
| 525 |
-
- Misc Kawaii
|
| 526 |
-
- Misc Lovecraftian
|
| 527 |
-
- Misc Macabre
|
| 528 |
-
- Misc Manga
|
| 529 |
-
- Misc Metropolis
|
| 530 |
-
- Misc Minimalist
|
| 531 |
-
- Misc Monochrome
|
| 532 |
-
- Misc Nautical
|
| 533 |
-
- Misc Space
|
| 534 |
-
- Misc Stained Glass
|
| 535 |
-
- Misc Techwear Fashion
|
| 536 |
-
- Misc Tribal
|
| 537 |
-
- Misc Zentangle
|
| 538 |
-
- Mk Adnate Style
|
| 539 |
-
- Mk Afrofuturism
|
| 540 |
-
- Mk Albumen Print
|
| 541 |
-
- Mk Alcohol Ink Art
|
| 542 |
-
- Mk Andy Warhol
|
| 543 |
-
- Mk Anthotype Print
|
| 544 |
-
- Mk Aquatint Print
|
| 545 |
-
- Mk Atompunk
|
| 546 |
-
- Mk Basquiat
|
| 547 |
-
- Mk Bauhaus Style
|
| 548 |
-
- Mk Blacklight Paint
|
| 549 |
-
- Mk Bromoil Print
|
| 550 |
-
- Mk Calotype Print
|
| 551 |
-
- Mk Carnival Glass
|
| 552 |
-
- Mk Chicano Art
|
| 553 |
-
- Mk Chromolithography
|
| 554 |
-
- Mk Cibulak Porcelain
|
| 555 |
-
- Mk Color Sketchnote
|
| 556 |
-
- Mk Coloring Book
|
| 557 |
-
- Mk Constructivism
|
| 558 |
-
- Mk Cross Processing Print
|
| 559 |
-
- Mk Cross Stitching
|
| 560 |
-
- Mk Cyanotype Print
|
| 561 |
-
- Mk Dayak Art
|
| 562 |
-
- Mk De Stijl
|
| 563 |
-
- Mk Dufaycolor Photograph
|
| 564 |
-
- Mk Embroidery
|
| 565 |
-
- Mk Encaustic Paint
|
| 566 |
-
- Mk Fayum Portrait
|
| 567 |
-
- Mk Gond Painting
|
| 568 |
-
- Mk Gyotaku
|
| 569 |
-
- Mk Halftone Print
|
| 570 |
-
- Mk Herbarium
|
| 571 |
-
- Mk Illuminated Manuscript
|
| 572 |
-
- Mk Inuit Carving
|
| 573 |
-
- Mk Kalighat Painting
|
| 574 |
-
- Mk Lite Brite Art
|
| 575 |
-
- Mk Luminogram
|
| 576 |
-
- Mk Madhubani Painting
|
| 577 |
-
- Mk Mokume Gane
|
| 578 |
-
- Mk Mosaic
|
| 579 |
-
- Mk One Line Art
|
| 580 |
-
- Mk Palekh
|
| 581 |
-
- Mk Patachitra Painting
|
| 582 |
-
- Mk Pichwai Painting
|
| 583 |
-
- Mk Pictorialism
|
| 584 |
-
- Mk Pollock
|
| 585 |
-
- Mk Punk Collage
|
| 586 |
-
- Mk Ron English Style
|
| 587 |
-
- Mk Samoan Art Inspired
|
| 588 |
-
- Mk Scrimshaw
|
| 589 |
-
- Mk Shepard Fairey Style
|
| 590 |
-
- Mk Shibori
|
| 591 |
-
- Mk Singer Sargent
|
| 592 |
-
- Mk Suminagashi
|
| 593 |
-
- Mk Tlingit Art
|
| 594 |
-
- Mk Ukiyo E
|
| 595 |
-
- Mk Van Gogh
|
| 596 |
-
- Mk Vintage Airline Poster
|
| 597 |
-
- Mk Vintage Travel Poster
|
| 598 |
-
- Mk Vitreous Enamel
|
| 599 |
-
- Neo Baroque
|
| 600 |
-
- Neo Byzantine
|
| 601 |
-
- Neo Futurism
|
| 602 |
-
- Neo Impressionism
|
| 603 |
-
- Neo Rococo
|
| 604 |
-
- Neoclassicism
|
| 605 |
-
- Op Art
|
| 606 |
-
- Ornate And Intricate
|
| 607 |
-
- Papercraft Collage
|
| 608 |
-
- Papercraft Flat Papercut
|
| 609 |
-
- Papercraft Kirigami
|
| 610 |
-
- Papercraft Paper Mache
|
| 611 |
-
- Papercraft Paper Quilling
|
| 612 |
-
- Papercraft Papercut Collage
|
| 613 |
-
- Papercraft Papercut Shadow Box
|
| 614 |
-
- Papercraft Stacked Papercut
|
| 615 |
-
- Papercraft Thick Layered Papercut
|
| 616 |
-
- Pebble Art
|
| 617 |
-
- Pencil Sketch Drawing
|
| 618 |
-
- Photo Alien
|
| 619 |
-
- Photo Film Noir
|
| 620 |
-
- Photo Glamour
|
| 621 |
-
- Photo Hdr
|
| 622 |
-
- Photo Iphone Photographic
|
| 623 |
-
- Photo Long Exposure
|
| 624 |
-
- Photo Neon Noir
|
| 625 |
-
- Photo Silhouette
|
| 626 |
-
- Photo Tilt Shift
|
| 627 |
-
- Pop Art 2
|
| 628 |
-
- Random Style
|
| 629 |
-
- Rococo
|
| 630 |
-
- SAI 3D Model
|
| 631 |
-
- SAI Analog Film
|
| 632 |
-
- SAI Anime
|
| 633 |
-
- SAI Cinematic
|
| 634 |
-
- SAI Comic Book
|
| 635 |
-
- SAI Craft Clay
|
| 636 |
-
- SAI Digital Art
|
| 637 |
-
- SAI Enhance
|
| 638 |
-
- SAI Fantasy Art
|
| 639 |
-
- SAI Isometric
|
| 640 |
-
- SAI Line Art
|
| 641 |
-
- SAI Lowpoly
|
| 642 |
-
- SAI Neonpunk
|
| 643 |
-
- SAI Origami
|
| 644 |
-
- SAI Photographic
|
| 645 |
-
- SAI Pixel Art
|
| 646 |
-
- SAI Texture
|
| 647 |
-
- Silhouette Art
|
| 648 |
-
- Simple Vector Art
|
| 649 |
-
- Sketchup
|
| 650 |
-
- Steampunk 2
|
| 651 |
-
- Sticker Designs
|
| 652 |
-
- Suprematism
|
| 653 |
-
- Surrealism
|
| 654 |
-
- Terragen
|
| 655 |
-
- Tranquil Relaxing Atmosphere
|
| 656 |
-
- Vibrant Rim Light
|
| 657 |
-
- Volumetric Lighting
|
| 658 |
-
- Watercolor 2
|
| 659 |
-
- Whimsical And Playful
|
| 660 |
-
sharpness:
|
| 661 |
-
order: 1
|
| 662 |
-
title: Sharpness
|
| 663 |
-
group: SDXL
|
| 664 |
-
type: integer
|
| 665 |
-
min: 0
|
| 666 |
-
max: 30
|
| 667 |
-
step: 1
|
| 668 |
-
default: 2
|
| 669 |
-
seed:
|
| 670 |
-
order: 8
|
| 671 |
-
title: Seed
|
| 672 |
-
group: base
|
| 673 |
-
type: integer
|
| 674 |
-
placeholder: no seed
|
| 675 |
outputs:
|
| 676 |
image:
|
| 677 |
-
title: Image
|
| 678 |
type: image
|
| 679 |
-
images:
|
| 680 |
-
title: Images
|
| 681 |
-
type: image[]
|
| 682 |
package: artworks
|
| 683 |
script: |-
|
| 684 |
-
const PAAS_BASE_URL = env.variables.get('PAAS_BASE_URL');
|
| 685 |
-
if(!PAAS_BASE_URL) {
|
| 686 |
-
error.fatal('Please, set PAAS_BASE_URL in environment');
|
| 687 |
-
}
|
| 688 |
-
const OPEN_PAAS_USER = env.variables.get('OPEN_PAAS_USER');
|
| 689 |
-
if(!OPEN_PAAS_USER) {
|
| 690 |
-
error.fatal('Please, set OPEN_PAAS_USER in environment');
|
| 691 |
-
}
|
| 692 |
-
const OPEN_PAAS_PASSWORD = env.variables.get('OPEN_PAAS_PASSWORD');
|
| 693 |
-
if(!OPEN_PAAS_PASSWORD) {
|
| 694 |
-
error.fatal('Please, set OPEN_PAAS_PASSWORD in environment');
|
| 695 |
-
}
|
| 696 |
-
const PAAS_AUTH = {
|
| 697 |
-
username: OPEN_PAAS_USER,
|
| 698 |
-
password: OPEN_PAAS_PASSWORD
|
| 699 |
-
};
|
| 700 |
const CHECK_TASK_INTERVAL = 3000;
|
|
|
|
| 701 |
|
| 702 |
-
function
|
| 703 |
-
return `${PAAS_BASE_URL}/api/v3/${path}`;
|
| 704 |
-
}
|
| 705 |
|
| 706 |
-
|
|
|
|
| 707 |
|
| 708 |
-
|
| 709 |
-
|
| 710 |
-
|
| 711 |
-
url: getUrl("tasks"),
|
| 712 |
-
headers: {
|
| 713 |
-
"Content-type": "application/json",
|
| 714 |
-
},
|
| 715 |
-
auth: PAAS_AUTH,
|
| 716 |
-
data: JSON.stringify(payload),
|
| 717 |
-
});
|
| 718 |
-
const {
|
| 719 |
-
id
|
| 720 |
-
} = response.data;
|
| 721 |
-
return id;
|
| 722 |
-
} catch (e) {
|
| 723 |
-
const {
|
| 724 |
-
errors
|
| 725 |
-
} = e.response?.data;
|
| 726 |
-
if (errors?.length > 0) {
|
| 727 |
-
error.data(errors.join(", "));
|
| 728 |
-
}
|
| 729 |
-
error.fatal(e.statusText);
|
| 730 |
}
|
| 731 |
-
|
| 732 |
-
|
| 733 |
-
|
| 734 |
-
log(`Cancel task ${id}`);
|
| 735 |
-
try {
|
| 736 |
-
await httpClient({
|
| 737 |
-
method: "post",
|
| 738 |
-
url: getUrl(`tasks/${id}/cancel`),
|
| 739 |
-
headers: {
|
| 740 |
-
"Content-type": "application/json",
|
| 741 |
-
},
|
| 742 |
-
auth: PAAS_AUTH,
|
| 743 |
-
});
|
| 744 |
-
} catch (e) {
|
| 745 |
-
const {
|
| 746 |
-
errors
|
| 747 |
-
} = e.response?.data;
|
| 748 |
-
if (errors?.length > 0) {
|
| 749 |
-
logger.error(errors.join(", "));
|
| 750 |
-
error.data(errors.join(", "));
|
| 751 |
-
}
|
| 752 |
-
error.fatal(e.statusText);
|
| 753 |
}
|
| 754 |
-
|
| 755 |
-
|
| 756 |
-
|
| 757 |
-
const {
|
| 758 |
-
data
|
| 759 |
-
} = await httpClient({
|
| 760 |
-
method: "get",
|
| 761 |
-
url: getUrl(`tasks/${id}`),
|
| 762 |
-
headers: {
|
| 763 |
-
"Content-type": "application/json",
|
| 764 |
-
},
|
| 765 |
-
auth: PAAS_AUTH,
|
| 766 |
-
});
|
| 767 |
-
|
| 768 |
-
const {
|
| 769 |
-
status,
|
| 770 |
-
results
|
| 771 |
-
} = data;
|
| 772 |
-
switch (status) {
|
| 773 |
-
case "preparing":
|
| 774 |
-
case "scheduling":
|
| 775 |
-
case "scheduled":
|
| 776 |
-
case "pending":
|
| 777 |
-
case "processing":
|
| 778 |
-
return null;
|
| 779 |
-
case "completed":
|
| 780 |
-
const {
|
| 781 |
-
data
|
| 782 |
-
} = results;
|
| 783 |
-
return data;
|
| 784 |
-
case "failed":
|
| 785 |
-
const {
|
| 786 |
-
error
|
| 787 |
-
} = results;
|
| 788 |
-
error.fatal(error);
|
| 789 |
-
default:
|
| 790 |
-
error.fatal("Wrong task status");
|
| 791 |
}
|
| 792 |
-
}
|
| 793 |
|
| 794 |
-
|
| 795 |
-
|
| 796 |
-
|
| 797 |
-
|
| 798 |
-
|
| 799 |
-
checkpoint,
|
| 800 |
-
cfgScale,
|
| 801 |
-
imageSize: size,
|
| 802 |
-
performance,
|
| 803 |
-
sharpness,
|
| 804 |
-
seed,
|
| 805 |
-
batchSize,
|
| 806 |
-
// SDXL
|
| 807 |
-
styles,
|
| 808 |
-
} = inputs;
|
| 809 |
|
| 810 |
if (!state) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 811 |
const payload = {
|
| 812 |
-
type: "
|
| 813 |
isFast: true,
|
| 814 |
payload: {
|
| 815 |
base64: false,
|
| 816 |
-
|
| 817 |
-
|
| 818 |
-
negativePrompt
|
| 819 |
-
} : {}),
|
| 820 |
-
checkpoint,
|
| 821 |
-
cfgScale,
|
| 822 |
-
size,
|
| 823 |
-
...(performance !== "speed" ? {
|
| 824 |
-
performance
|
| 825 |
-
} : {}),
|
| 826 |
-
...(seed > 0 ? {
|
| 827 |
-
seed
|
| 828 |
-
} : {}),
|
| 829 |
-
...(batchSize > 1 ? {
|
| 830 |
-
batchSize
|
| 831 |
-
} : {}),
|
| 832 |
-
// SDXL
|
| 833 |
-
...(styles?.length > 0 ? {
|
| 834 |
-
styles
|
| 835 |
-
} : {}),
|
| 836 |
-
...(sharpness > 2 ? {
|
| 837 |
-
sharpness
|
| 838 |
-
} : {}),
|
| 839 |
},
|
| 840 |
};
|
| 841 |
-
|
| 842 |
-
|
| 843 |
-
|
| 844 |
-
|
| 845 |
-
|
| 846 |
-
|
| 847 |
-
|
| 848 |
-
|
| 849 |
-
|
| 850 |
-
|
| 851 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 852 |
} else {
|
| 853 |
const {
|
| 854 |
payload,
|
|
@@ -856,38 +1644,50 @@ nodes:
|
|
| 856 |
attempt,
|
| 857 |
startedAt
|
| 858 |
} = state;
|
| 859 |
-
|
| 860 |
-
|
|
|
|
|
|
|
|
|
|
| 861 |
|
| 862 |
const now = new Date();
|
| 863 |
const time = (now - new Date(startedAt)) / 1000;
|
| 864 |
-
|
| 865 |
}
|
| 866 |
|
| 867 |
-
log(`Check task ${attempt} ${task}`);
|
| 868 |
-
|
| 869 |
-
|
| 870 |
-
|
| 871 |
-
|
| 872 |
-
|
| 873 |
-
|
| 874 |
-
|
| 875 |
-
|
| 876 |
-
|
| 877 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 878 |
});
|
| 879 |
-
}
|
| 880 |
-
|
| 881 |
-
|
| 882 |
-
return next({
|
| 883 |
-
outputs: {
|
| 884 |
-
images,
|
| 885 |
-
image: image
|
| 886 |
}
|
| 887 |
-
|
|
|
|
| 888 |
}
|
| 889 |
-
|
| 890 |
-
})();
|
| 891 |
source: catalog
|
| 892 |
-
title: en=
|
| 893 |
version: 1
|
|
|
|
| 5 |
url: https://huggingface.co/PiperMy/Node-Packages/resolve/main/artworks.yaml
|
| 6 |
version: 2
|
| 7 |
nodes:
|
| 8 |
+
inpaint_image_artworks:
|
| 9 |
+
_id: inpaint_image_artworks
|
| 10 |
arrange:
|
| 11 |
+
x: 440
|
| 12 |
+
y: 60
|
| 13 |
category:
|
| 14 |
+
id: generate_images
|
| 15 |
+
title: en=Generate images;ru=Генерация изображений
|
| 16 |
+
groups:
|
| 17 |
+
inputs:
|
| 18 |
+
mask:
|
| 19 |
+
order: 2
|
| 20 |
+
title: en=Mask;ru=Маска
|
| 21 |
+
SDXL:
|
| 22 |
+
order: 4
|
| 23 |
+
title: SDXL checkpoints
|
| 24 |
+
description: Only for SDXL checkpoints
|
| 25 |
+
base:
|
| 26 |
+
order: 1
|
| 27 |
+
title: en=Base;ru=Базовые параметры
|
| 28 |
+
special:
|
| 29 |
+
order: 3
|
| 30 |
+
title: en=Special;ru=Специальные возможности
|
| 31 |
+
inputs:
|
| 32 |
+
image:
|
| 33 |
+
order: 1
|
| 34 |
+
title: en=Image;ru=Изображение
|
| 35 |
+
group: base
|
| 36 |
+
type: image
|
| 37 |
+
required: true
|
| 38 |
+
extensions:
|
| 39 |
+
- id: draw-mask
|
| 40 |
+
params:
|
| 41 |
+
mask: mask
|
| 42 |
+
prompt:
|
| 43 |
+
order: 2
|
| 44 |
+
title: en=Prompt;ru=Подсказка
|
| 45 |
+
group: base
|
| 46 |
+
type: string
|
| 47 |
+
required: true
|
| 48 |
+
multiline: true
|
| 49 |
+
negativePrompt:
|
| 50 |
+
order: 4
|
| 51 |
+
title: en=Negative prompt;ru=Негативная подсказка
|
| 52 |
+
group: base
|
| 53 |
+
type: string
|
| 54 |
+
multiline: true
|
| 55 |
+
checkpoint:
|
| 56 |
+
order: 3
|
| 57 |
+
title: en=Checkpoint;ru=Модель
|
| 58 |
+
group: base
|
| 59 |
+
type: string
|
| 60 |
+
required: true
|
| 61 |
+
default: juggernautXL_v9Rundiffusionphoto2.safetensors
|
| 62 |
+
enum:
|
| 63 |
+
- raemuXL_v40.safetensors|Raemu XL <SDXL>
|
| 64 |
+
- aamXLAnimeMix_v10.safetensors|AAM XL (Anime Mix) <SDXL> <Fantasy>
|
| 65 |
+
- dreamweaverPony25D.1erv.safetensors|DreamWeaver - Pony 2.5D Mix <SDXL>
|
| 66 |
+
- mixGEMAdam8witQegoow.NeWz.safetensors|MyMIX-G/Jem <SDXL> <Realistic>
|
| 67 |
+
- mfcgPDXL_v10.safetensors|MFCG PDXL <SDXL>
|
| 68 |
+
- aniku_0.2.fp16.safetensors|Anime Desire <SDXL> <Fantasy>
|
| 69 |
+
- flux1DevHyperNF4Flux1DevBNB_flux1DevHyperNF4.safetensors|Hyper NF4 Flux 1 <Flux>
|
| 70 |
+
- STOIQONewrealityFLUXSD_F1DPreAlpha.safetensors|New Reality Flux <Flux>
|
| 71 |
+
- juggernautXL_v9Rundiffusionphoto2.safetensors|Juggernaut XL <SDXL>
|
| 72 |
+
- animaPencilXL_v260.safetensors|Anima Pencil XL <SDXL> <Fantasy>
|
| 73 |
+
- bluePencilXL_v401.safetensors|Blue Pencil XL <SDXL> <Fantasy>
|
| 74 |
+
- pixelArtDiffusionXL_spriteShaper.safetensors|Pixel Art Diffusion XL <SDXL> <Fantasy>
|
| 75 |
+
- albedobaseXL_v20.safetensors|AlbedoBase XL <SDXL>
|
| 76 |
+
- leosamsHelloworldXL_helloworldXL50GPT4V.safetensors|Helloworld XL <SDXL>
|
| 77 |
+
- dynavisionXLAllInOneStylized_releaseV0610Bakedvae.safetensors|DynaVision XL All In One <SDXL>
|
| 78 |
+
- photon_v1.safetensors|Photon <SD 1.5>
|
| 79 |
+
- afroditexlNudePeople_20Bkdvae.safetensors|Nude People <NSFW>
|
| 80 |
+
- nosft-float8-e4m3fn.safetensors|Flux Nude People <NSFW>
|
| 81 |
+
- asdf_0.4a_lorapov_0.2_lust_0.4.fp16.safetensors|Real Porn <NSFW>
|
| 82 |
+
- Sexy_Aesthetic_SDXL_0.4x0.2.fp16.safetensors|Sexy & Beauty <NSFW>
|
| 83 |
+
- aniku_0.2.fp16.safetensors|Anime Desire <NSFW>
|
| 84 |
+
- anikurender_0.4b.fp16.safetensors|Hardcore Fantasy <NSFW>
|
| 85 |
+
denoisingStrength:
|
| 86 |
+
order: 6
|
| 87 |
+
title: en=Denoising strength;ru=Степень изменения
|
| 88 |
+
group: base
|
| 89 |
+
type: float
|
| 90 |
+
required: true
|
| 91 |
+
min: 0.1
|
| 92 |
+
max: 1
|
| 93 |
+
step: 0.05
|
| 94 |
+
default: 0.5
|
| 95 |
+
cfgScale:
|
| 96 |
+
order: 7
|
| 97 |
+
title: en=CFG scale;ru=Креативность
|
| 98 |
+
group: base
|
| 99 |
+
type: integer
|
| 100 |
+
required: true
|
| 101 |
+
min: 1
|
| 102 |
+
max: 20
|
| 103 |
+
step: 1
|
| 104 |
+
default: 7
|
| 105 |
+
imageSize:
|
| 106 |
+
order: 5
|
| 107 |
+
title: en=Image size;ru=Размер изображения
|
| 108 |
+
group: base
|
| 109 |
+
type: string
|
| 110 |
+
placeholder: auto:auto
|
| 111 |
+
default: auto:auto
|
| 112 |
+
enum:
|
| 113 |
+
- auto:1024
|
| 114 |
+
- 1024:auto
|
| 115 |
+
- auto:auto
|
| 116 |
+
performance:
|
| 117 |
+
order: 8
|
| 118 |
+
title: en=Performance;ru=Производительность
|
| 119 |
+
group: base
|
| 120 |
+
type: string
|
| 121 |
+
default: speed
|
| 122 |
+
enum:
|
| 123 |
+
- express|⚡ Express
|
| 124 |
+
- speed|🚅 Speed
|
| 125 |
+
- quality|💎 Quality
|
| 126 |
+
controlNets:
|
| 127 |
+
order: 1
|
| 128 |
+
title: en=Control nets;ru=Контрольные сети
|
| 129 |
+
group: special
|
| 130 |
+
type: json
|
| 131 |
+
schema:
|
| 132 |
+
id: control-nets
|
| 133 |
+
seed:
|
| 134 |
+
order: 10
|
| 135 |
+
title: en=Seed;ru=Начальный шум
|
| 136 |
+
group: base
|
| 137 |
+
type: integer
|
| 138 |
+
batchSize:
|
| 139 |
+
order: 9
|
| 140 |
+
title: en=Batch size;ru=Кол-во
|
| 141 |
+
group: base
|
| 142 |
+
type: integer
|
| 143 |
+
min: 1
|
| 144 |
+
max: 4
|
| 145 |
+
step: 1
|
| 146 |
+
default: 1
|
| 147 |
+
mask:
|
| 148 |
+
order: 1
|
| 149 |
+
title: en=Mask;ru=Маска
|
| 150 |
+
group: mask
|
| 151 |
+
type: image
|
| 152 |
+
required: true
|
| 153 |
+
invertMask:
|
| 154 |
+
order: 1
|
| 155 |
+
title: en=Invert mask;ru=Инвертировать маску
|
| 156 |
+
group: SDXL
|
| 157 |
+
type: boolean
|
| 158 |
+
default: false
|
| 159 |
+
maskMargin:
|
| 160 |
+
order: 2
|
| 161 |
+
title: en=Mask margin;ru=Отступ от маски
|
| 162 |
+
group: mask
|
| 163 |
+
type: integer
|
| 164 |
+
default: 10
|
| 165 |
+
outputs:
|
| 166 |
+
image1:
|
| 167 |
+
title: en=Image 1;ru=Изображение 1
|
| 168 |
+
type: image
|
| 169 |
+
images:
|
| 170 |
+
title: en=Images;ru=Изображения
|
| 171 |
+
type: image[]
|
| 172 |
+
image2:
|
| 173 |
+
title: en=Image 2;ru=Изображение 2
|
| 174 |
+
type: image
|
| 175 |
+
image3:
|
| 176 |
+
title: en=Image 3;ru=Изображение 3
|
| 177 |
+
type: image
|
| 178 |
+
image4:
|
| 179 |
+
title: en=Image 4;ru=Изображение 4
|
| 180 |
+
type: image
|
| 181 |
+
package: artworks
|
| 182 |
+
script: |
|
| 183 |
+
const CHECK_TASK_INTERVAL = 3000;
|
| 184 |
+
const MAX_ATTEMPTS = 100;
|
| 185 |
+
|
| 186 |
+
export async function run({ inputs, state }) {
|
| 187 |
+
|
| 188 |
+
const { FatalError, TimeoutError, RepeatNode, NextNode } = DEFINITIONS;
|
| 189 |
+
const { ArtWorks, fitSize, FatalError: ArtWorksError } = require('artworks');
|
| 190 |
+
const sharp = require('sharp/lib/index.js');
|
| 191 |
+
|
| 192 |
+
const PAAS_BASE_URL = env.variables.get('PAAS_BASE_URL');
|
| 193 |
+
if (!PAAS_BASE_URL) {
|
| 194 |
+
throw new FatalError('Please, set PAAS_BASE_URL in environment');
|
| 195 |
+
}
|
| 196 |
+
const OPEN_PAAS_USER = env.variables.get('OPEN_PAAS_USER');
|
| 197 |
+
if (!OPEN_PAAS_USER) {
|
| 198 |
+
throw new FatalError('Please, set OPEN_PAAS_USER in environment');
|
| 199 |
+
}
|
| 200 |
+
const OPEN_PAAS_PASSWORD = env.variables.get('OPEN_PAAS_PASSWORD');
|
| 201 |
+
if (!OPEN_PAAS_PASSWORD) {
|
| 202 |
+
throw new FatalError('Please, set OPEN_PAAS_PASSWORD in environment');
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
const artworks = new ArtWorks({
|
| 206 |
+
baseUrl: PAAS_BASE_URL,
|
| 207 |
+
username: OPEN_PAAS_USER,
|
| 208 |
+
password: OPEN_PAAS_PASSWORD
|
| 209 |
+
});
|
| 210 |
+
|
| 211 |
+
if (!state) {
|
| 212 |
+
const {
|
| 213 |
+
image,
|
| 214 |
+
prompt,
|
| 215 |
+
checkpoint,
|
| 216 |
+
negativePrompt,
|
| 217 |
+
imageSize,
|
| 218 |
+
denoisingStrength,
|
| 219 |
+
cfgScale,
|
| 220 |
+
performance,
|
| 221 |
+
batchSize,
|
| 222 |
+
seed,
|
| 223 |
+
// mask
|
| 224 |
+
mask,
|
| 225 |
+
maskMargin,
|
| 226 |
+
// special
|
| 227 |
+
controlNets,
|
| 228 |
+
// SDXL
|
| 229 |
+
invertMask,
|
| 230 |
+
} = inputs;
|
| 231 |
+
const payload = {
|
| 232 |
+
type: "inpaint-on-image",
|
| 233 |
+
isFast: true,
|
| 234 |
+
payload: {
|
| 235 |
+
base64: false,
|
| 236 |
+
image,
|
| 237 |
+
prompt,
|
| 238 |
+
checkpoint,
|
| 239 |
+
negativePrompt,
|
| 240 |
+
...(!!imageSize
|
| 241 |
+
? await (async () => {
|
| 242 |
+
const { data } = await download(image);
|
| 243 |
+
const buffer = sharp(data);
|
| 244 |
+
const { width, height } = await buffer.metadata();
|
| 245 |
+
if (imageSize !== "auto:auto") {
|
| 246 |
+
const { width: w, height: h } = fitSize(imageSize, height / width);
|
| 247 |
+
return { size: `${w}x${h}` };
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
return {};
|
| 251 |
+
})()
|
| 252 |
+
: {}),
|
| 253 |
+
denoisingStrength,
|
| 254 |
+
cfgScale,
|
| 255 |
+
performance,
|
| 256 |
+
...(batchSize > 1 ? { batchSize } : {}),
|
| 257 |
+
seed,
|
| 258 |
+
// mask
|
| 259 |
+
mask,
|
| 260 |
+
maskMargin,
|
| 261 |
+
// special
|
| 262 |
+
controlNets,
|
| 263 |
+
// SDXL
|
| 264 |
+
invertMask
|
| 265 |
+
},
|
| 266 |
+
};
|
| 267 |
+
try {
|
| 268 |
+
const task = await artworks.createTask(payload);
|
| 269 |
+
console.log(`Task created ${task}`);
|
| 270 |
+
return RepeatNode.from({
|
| 271 |
+
state: {
|
| 272 |
+
payload,
|
| 273 |
+
task,
|
| 274 |
+
attempt: 0,
|
| 275 |
+
startedAt: new Date()
|
| 276 |
+
},
|
| 277 |
+
progress: {
|
| 278 |
+
total: MAX_ATTEMPTS,
|
| 279 |
+
processed: 0
|
| 280 |
+
},
|
| 281 |
+
delay: 2000
|
| 282 |
+
});
|
| 283 |
+
} catch (e) {
|
| 284 |
+
if (e instanceof ArtWorksError) {
|
| 285 |
+
throw new FatalError(e.message);
|
| 286 |
+
}
|
| 287 |
+
throw e;
|
| 288 |
+
}
|
| 289 |
+
} else {
|
| 290 |
+
const {
|
| 291 |
+
payload,
|
| 292 |
+
task,
|
| 293 |
+
attempt,
|
| 294 |
+
startedAt
|
| 295 |
+
} = state;
|
| 296 |
+
|
| 297 |
+
if (attempt > MAX_ATTEMPTS) {
|
| 298 |
+
try {
|
| 299 |
+
await artworks.cancelTask(task);
|
| 300 |
+
} catch (e) { }
|
| 301 |
+
|
| 302 |
+
const now = new Date();
|
| 303 |
+
const time = (now - new Date(startedAt)) / 1000;
|
| 304 |
+
throw new TimeoutError(`PaaS task for text to image ${task} timeout in ${time} sec`);
|
| 305 |
+
}
|
| 306 |
+
|
| 307 |
+
console.log(`Check task ${attempt} ${task}`);
|
| 308 |
+
|
| 309 |
+
try {
|
| 310 |
+
const results = await artworks.checkState(task);
|
| 311 |
+
if (!results) {
|
| 312 |
+
return RepeatNode.from({
|
| 313 |
+
delay: CHECK_TASK_INTERVAL,
|
| 314 |
+
state: {
|
| 315 |
+
payload,
|
| 316 |
+
task,
|
| 317 |
+
attempt: attempt + 1,
|
| 318 |
+
startedAt,
|
| 319 |
+
},
|
| 320 |
+
progress: {
|
| 321 |
+
total: MAX_ATTEMPTS,
|
| 322 |
+
processed: attempt
|
| 323 |
+
},
|
| 324 |
+
});
|
| 325 |
+
}
|
| 326 |
+
let images = results.images.map((i) => i.url);
|
| 327 |
+
const [image1, image2, image3, image4] = images;
|
| 328 |
+
return NextNode.from({
|
| 329 |
+
outputs: {
|
| 330 |
+
images,
|
| 331 |
+
image1,
|
| 332 |
+
image2,
|
| 333 |
+
image3,
|
| 334 |
+
image4
|
| 335 |
+
}
|
| 336 |
+
});
|
| 337 |
+
} catch (e) {
|
| 338 |
+
if (e instanceof ArtWorksError) {
|
| 339 |
+
throw new FatalError(e.message);
|
| 340 |
+
}
|
| 341 |
+
throw e;
|
| 342 |
+
}
|
| 343 |
+
}
|
| 344 |
+
}
|
| 345 |
+
source: catalog
|
| 346 |
+
title: en=Inpaint on image;ru=Улучшить изображение
|
| 347 |
+
version: 1
|
| 348 |
+
environment:
|
| 349 |
+
OPEN_PAAS_USER:
|
| 350 |
+
title: PaaS user
|
| 351 |
+
type: string
|
| 352 |
+
scope: global
|
| 353 |
+
OPEN_PAAS_PASSWORD:
|
| 354 |
+
title: PaaS password
|
| 355 |
+
type: string
|
| 356 |
+
scope: global
|
| 357 |
+
PAAS_BASE_URL:
|
| 358 |
+
title: PaaS base url
|
| 359 |
+
type: string
|
| 360 |
+
scope: global
|
| 361 |
+
face_swap_on_image:
|
| 362 |
+
_id: face_swap_on_image
|
| 363 |
+
arrange:
|
| 364 |
+
x: 760
|
| 365 |
+
y: 180
|
| 366 |
+
category:
|
| 367 |
+
id: deep_swap
|
| 368 |
+
title: en=Deep swap;ru=Глубокая замена
|
| 369 |
+
environment:
|
| 370 |
+
OPEN_PAAS_USER:
|
| 371 |
+
title: PaaS user
|
| 372 |
+
type: string
|
| 373 |
+
scope: global
|
| 374 |
+
OPEN_PAAS_PASSWORD:
|
| 375 |
+
title: PaaS password
|
| 376 |
+
type: string
|
| 377 |
+
scope: global
|
| 378 |
+
PAAS_BASE_URL:
|
| 379 |
+
title: PaaS base url
|
| 380 |
+
type: string
|
| 381 |
+
scope: global
|
| 382 |
+
inputs:
|
| 383 |
+
face:
|
| 384 |
+
order: 1
|
| 385 |
+
title: en=Face;ru=Лицо
|
| 386 |
+
type: image
|
| 387 |
+
required: true
|
| 388 |
+
image:
|
| 389 |
+
order: 2
|
| 390 |
+
title: en=Image;ru=Изображение
|
| 391 |
+
type: image
|
| 392 |
+
required: true
|
| 393 |
+
outputs:
|
| 394 |
+
image:
|
| 395 |
+
title: en=Image;ru=Изображение
|
| 396 |
+
type: image
|
| 397 |
+
package: artworks
|
| 398 |
+
script: |
|
| 399 |
+
const CHECK_TASK_INTERVAL = 3000;
|
| 400 |
+
const MAX_ATTEMPTS = 20;
|
| 401 |
+
|
| 402 |
+
export async function run({ inputs, state }) {
|
| 403 |
+
|
| 404 |
+
const { FatalError, TimeoutError, RepeatNode, NextNode } = DEFINITIONS;
|
| 405 |
+
const { ArtWorks, FatalError: ArtWorksError } = require('artworks');
|
| 406 |
+
|
| 407 |
+
const PAAS_BASE_URL = env.variables.get('PAAS_BASE_URL');
|
| 408 |
+
if (!PAAS_BASE_URL) {
|
| 409 |
+
throw new FatalError('Please, set PAAS_BASE_URL in environment');
|
| 410 |
+
}
|
| 411 |
+
const OPEN_PAAS_USER = env.variables.get('OPEN_PAAS_USER');
|
| 412 |
+
if (!OPEN_PAAS_USER) {
|
| 413 |
+
throw new FatalError('Please, set OPEN_PAAS_USER in environment');
|
| 414 |
+
}
|
| 415 |
+
const OPEN_PAAS_PASSWORD = env.variables.get('OPEN_PAAS_PASSWORD');
|
| 416 |
+
if (!OPEN_PAAS_PASSWORD) {
|
| 417 |
+
throw new FatalError('Please, set OPEN_PAAS_PASSWORD in environment');
|
| 418 |
+
}
|
| 419 |
+
|
| 420 |
+
const artworks = new ArtWorks({
|
| 421 |
+
baseUrl: PAAS_BASE_URL,
|
| 422 |
+
username: OPEN_PAAS_USER,
|
| 423 |
+
password: OPEN_PAAS_PASSWORD
|
| 424 |
+
});
|
| 425 |
+
|
| 426 |
+
if (!state) {
|
| 427 |
+
const {
|
| 428 |
+
face,
|
| 429 |
+
image
|
| 430 |
+
} = inputs;
|
| 431 |
+
|
| 432 |
+
const payload = {
|
| 433 |
+
type: "faceswap-on-image",
|
| 434 |
+
isFast: true,
|
| 435 |
+
payload: {
|
| 436 |
+
base64: false,
|
| 437 |
+
face,
|
| 438 |
+
image,
|
| 439 |
+
}
|
| 440 |
+
};
|
| 441 |
+
try {
|
| 442 |
+
const task = await artworks.createTask(payload);
|
| 443 |
+
console.log(`Task created ${task}`);
|
| 444 |
+
return RepeatNode.from({
|
| 445 |
+
state: {
|
| 446 |
+
payload,
|
| 447 |
+
task,
|
| 448 |
+
attempt: 0,
|
| 449 |
+
startedAt: new Date()
|
| 450 |
+
},
|
| 451 |
+
progress: {
|
| 452 |
+
total: MAX_ATTEMPTS,
|
| 453 |
+
processed: 0
|
| 454 |
+
},
|
| 455 |
+
delay: 2000
|
| 456 |
+
});
|
| 457 |
+
} catch (e) {
|
| 458 |
+
if (e instanceof ArtWorksError) {
|
| 459 |
+
throw new FatalError(e.message);
|
| 460 |
+
}
|
| 461 |
+
throw e;
|
| 462 |
+
}
|
| 463 |
+
} else {
|
| 464 |
+
const {
|
| 465 |
+
payload,
|
| 466 |
+
task,
|
| 467 |
+
attempt,
|
| 468 |
+
startedAt
|
| 469 |
+
} = state;
|
| 470 |
+
|
| 471 |
+
if (attempt > MAX_ATTEMPTS) {
|
| 472 |
+
try {
|
| 473 |
+
await artworks.cancelTask(task);
|
| 474 |
+
} catch (e) { }
|
| 475 |
+
|
| 476 |
+
const now = new Date();
|
| 477 |
+
const time = (now - new Date(startedAt)) / 1000;
|
| 478 |
+
throw new TimeoutError(`PaaS task for text to image ${task} timeout in ${time} sec`);
|
| 479 |
+
}
|
| 480 |
+
|
| 481 |
+
console.log(`Check task ${attempt} ${task}`);
|
| 482 |
+
|
| 483 |
+
try {
|
| 484 |
+
const results = await artworks.checkState(task);
|
| 485 |
+
if (!results) {
|
| 486 |
+
return RepeatNode.from({
|
| 487 |
+
delay: CHECK_TASK_INTERVAL,
|
| 488 |
+
state: {
|
| 489 |
+
payload,
|
| 490 |
+
task,
|
| 491 |
+
attempt: attempt + 1,
|
| 492 |
+
startedAt,
|
| 493 |
+
},
|
| 494 |
+
progress: {
|
| 495 |
+
total: MAX_ATTEMPTS,
|
| 496 |
+
processed: attempt
|
| 497 |
+
},
|
| 498 |
+
});
|
| 499 |
+
}
|
| 500 |
+
let { images: [{ url: image }] } = results;
|
| 501 |
+
return NextNode.from({
|
| 502 |
+
outputs: {
|
| 503 |
+
image
|
| 504 |
+
}
|
| 505 |
+
});
|
| 506 |
+
} catch (e) {
|
| 507 |
+
if (e instanceof ArtWorksError) {
|
| 508 |
+
throw new FatalError(e.message);
|
| 509 |
+
}
|
| 510 |
+
throw e;
|
| 511 |
+
}
|
| 512 |
+
}
|
| 513 |
+
}
|
| 514 |
+
source: catalog
|
| 515 |
+
title: en=Face swap on image;ru=Замена лица на изображении
|
| 516 |
+
version: 1
|
| 517 |
+
translate_text:
|
| 518 |
+
_id: translate_text
|
| 519 |
+
arrange:
|
| 520 |
+
x: 770
|
| 521 |
+
y: 370
|
| 522 |
+
category:
|
| 523 |
+
id: process_text
|
| 524 |
+
title: en=Process text;ru=Обработка текста
|
| 525 |
+
inputs:
|
| 526 |
+
source:
|
| 527 |
+
order: 1
|
| 528 |
+
title: Source language
|
| 529 |
+
type: string
|
| 530 |
+
required: true
|
| 531 |
+
default: auto
|
| 532 |
+
enum:
|
| 533 |
+
- auto|Auto
|
| 534 |
+
- en|English
|
| 535 |
+
- de|German
|
| 536 |
+
- ru|Russian
|
| 537 |
+
- es|Spanish
|
| 538 |
+
- fr|French
|
| 539 |
+
- it|Italian
|
| 540 |
+
- pt|Portuguese
|
| 541 |
+
- ja|Japanese
|
| 542 |
+
- ko|Korean
|
| 543 |
+
- hi|Hindi
|
| 544 |
+
- tr|Turkish
|
| 545 |
+
- zh|Chinese Simplified
|
| 546 |
+
target:
|
| 547 |
+
order: 2
|
| 548 |
+
title: Target
|
| 549 |
+
description: github://generative-core/piper/main/docs/nodes/translate-text/target.md
|
| 550 |
+
type: string
|
| 551 |
+
required: true
|
| 552 |
+
default: de
|
| 553 |
+
enum:
|
| 554 |
+
- en|English
|
| 555 |
+
- de|German
|
| 556 |
+
- ru|Russian
|
| 557 |
+
- es|Spanish
|
| 558 |
+
- fr|French
|
| 559 |
+
- it|Italian
|
| 560 |
+
- pt|Portuguese
|
| 561 |
+
- ja|Japanese
|
| 562 |
+
- ko|Korean
|
| 563 |
+
- hi|Hindi
|
| 564 |
+
- tr|Turkish
|
| 565 |
+
- zh|Chinese Simplified
|
| 566 |
+
text:
|
| 567 |
+
order: 3
|
| 568 |
+
title: Text
|
| 569 |
+
type: string
|
| 570 |
+
required: true
|
| 571 |
+
multiline: true
|
| 572 |
+
outputs:
|
| 573 |
+
text:
|
| 574 |
+
title: Text
|
| 575 |
+
type: string
|
| 576 |
+
alternatives:
|
| 577 |
+
title: Alternatives
|
| 578 |
+
type: string[]
|
| 579 |
+
detectedLanguage:
|
| 580 |
+
title: Detected language
|
| 581 |
+
type: json
|
| 582 |
+
schema: detected-languages
|
| 583 |
+
package: artworks
|
| 584 |
+
source: catalog
|
| 585 |
+
title: en=Translate text;ru=Перевести текст
|
| 586 |
+
version: 1
|
| 587 |
+
environment:
|
| 588 |
+
OPEN_PAAS_USER:
|
| 589 |
+
title: PaaS user
|
| 590 |
+
type: string
|
| 591 |
+
scope: global
|
| 592 |
+
OPEN_PAAS_PASSWORD:
|
| 593 |
+
title: PaaS password
|
| 594 |
+
type: string
|
| 595 |
+
scope: global
|
| 596 |
+
PAAS_BASE_URL:
|
| 597 |
+
title: PaaS base url
|
| 598 |
+
type: string
|
| 599 |
+
scope: global
|
| 600 |
+
script: |
|
| 601 |
+
const CHECK_TASK_INTERVAL = 3000;
|
| 602 |
+
const MAX_ATTEMPTS = 10;
|
| 603 |
+
|
| 604 |
+
export async function run({ inputs, state }) {
|
| 605 |
+
|
| 606 |
+
const { FatalError, TimeoutError, RepeatNode, NextNode } = DEFINITIONS;
|
| 607 |
+
const { ArtWorks, FatalError: ArtWorksError } = require('artworks');
|
| 608 |
+
|
| 609 |
+
const PAAS_BASE_URL = env.variables.get('PAAS_BASE_URL');
|
| 610 |
+
if (!PAAS_BASE_URL) {
|
| 611 |
+
throw new FatalError('Please, set PAAS_BASE_URL in environment');
|
| 612 |
+
}
|
| 613 |
+
const OPEN_PAAS_USER = env.variables.get('OPEN_PAAS_USER');
|
| 614 |
+
if (!OPEN_PAAS_USER) {
|
| 615 |
+
throw new FatalError('Please, set OPEN_PAAS_USER in environment');
|
| 616 |
+
}
|
| 617 |
+
const OPEN_PAAS_PASSWORD = env.variables.get('OPEN_PAAS_PASSWORD');
|
| 618 |
+
if (!OPEN_PAAS_PASSWORD) {
|
| 619 |
+
throw new FatalError('Please, set OPEN_PAAS_PASSWORD in environment');
|
| 620 |
+
}
|
| 621 |
+
|
| 622 |
+
const artworks = new ArtWorks({
|
| 623 |
+
baseUrl: PAAS_BASE_URL,
|
| 624 |
+
username: OPEN_PAAS_USER,
|
| 625 |
+
password: OPEN_PAAS_PASSWORD
|
| 626 |
+
});
|
| 627 |
+
|
| 628 |
+
if (!state) {
|
| 629 |
+
const { source, target, text } = inputs;
|
| 630 |
+
|
| 631 |
+
const payload = {
|
| 632 |
+
type: "translate-text",
|
| 633 |
+
isFast: true,
|
| 634 |
+
payload: {
|
| 635 |
+
source,
|
| 636 |
+
target,
|
| 637 |
+
text,
|
| 638 |
+
},
|
| 639 |
+
};
|
| 640 |
+
try {
|
| 641 |
+
const task = await artworks.createTask(payload);
|
| 642 |
+
console.log(`Task created ${task}`);
|
| 643 |
+
return RepeatNode.from({
|
| 644 |
+
state: {
|
| 645 |
+
payload,
|
| 646 |
+
task,
|
| 647 |
+
attempt: 0,
|
| 648 |
+
startedAt: new Date()
|
| 649 |
+
},
|
| 650 |
+
progress: {
|
| 651 |
+
total: MAX_ATTEMPTS,
|
| 652 |
+
processed: 0
|
| 653 |
+
},
|
| 654 |
+
delay: 2000
|
| 655 |
+
});
|
| 656 |
+
} catch (e) {
|
| 657 |
+
if (e instanceof ArtWorksError) {
|
| 658 |
+
throw new FatalError(e.message);
|
| 659 |
+
}
|
| 660 |
+
throw e;
|
| 661 |
+
}
|
| 662 |
+
} else {
|
| 663 |
+
const {
|
| 664 |
+
payload,
|
| 665 |
+
task,
|
| 666 |
+
attempt,
|
| 667 |
+
startedAt
|
| 668 |
+
} = state;
|
| 669 |
+
|
| 670 |
+
if (attempt > MAX_ATTEMPTS) {
|
| 671 |
+
try {
|
| 672 |
+
await artworks.cancelTask(task);
|
| 673 |
+
} catch (e) { }
|
| 674 |
+
|
| 675 |
+
const now = new Date();
|
| 676 |
+
const time = (now - new Date(startedAt)) / 1000;
|
| 677 |
+
throw new TimeoutError(`PaaS task for text to image ${task} timeout in ${time} sec`);
|
| 678 |
+
}
|
| 679 |
+
|
| 680 |
+
console.log(`Check task ${attempt} ${task}`);
|
| 681 |
+
|
| 682 |
+
try {
|
| 683 |
+
const results = await artworks.checkState(task);
|
| 684 |
+
if (!results) {
|
| 685 |
+
return RepeatNode.from({
|
| 686 |
+
delay: CHECK_TASK_INTERVAL,
|
| 687 |
+
state: {
|
| 688 |
+
payload,
|
| 689 |
+
task,
|
| 690 |
+
attempt: attempt + 1,
|
| 691 |
+
startedAt,
|
| 692 |
+
},
|
| 693 |
+
progress: {
|
| 694 |
+
total: MAX_ATTEMPTS,
|
| 695 |
+
processed: attempt
|
| 696 |
+
},
|
| 697 |
+
});
|
| 698 |
+
}
|
| 699 |
+
console.log(results);
|
| 700 |
+
const { alternatives, detectedLanguage, text } = results;
|
| 701 |
+
return NextNode.from({
|
| 702 |
+
outputs: {
|
| 703 |
+
alternatives,
|
| 704 |
+
detectedLanguage,
|
| 705 |
+
text
|
| 706 |
+
}
|
| 707 |
+
});
|
| 708 |
+
} catch (e) {
|
| 709 |
+
if (e instanceof ArtWorksError) {
|
| 710 |
+
throw new FatalError(e.message);
|
| 711 |
+
}
|
| 712 |
+
throw e;
|
| 713 |
+
}
|
| 714 |
+
}
|
| 715 |
+
}
|
| 716 |
+
upscale_image:
|
| 717 |
+
_id: upscale_image
|
| 718 |
+
arrange:
|
| 719 |
+
x: 100
|
| 720 |
+
y: 410
|
| 721 |
+
category:
|
| 722 |
+
id: generate_images
|
| 723 |
+
title: en=Generate images;ru=Генерация изображений
|
| 724 |
+
environment:
|
| 725 |
+
OPEN_PAAS_USER:
|
| 726 |
+
title: PaaS user
|
| 727 |
+
type: string
|
| 728 |
+
scope: global
|
| 729 |
+
OPEN_PAAS_PASSWORD:
|
| 730 |
+
title: PaaS password
|
| 731 |
+
type: string
|
| 732 |
+
scope: global
|
| 733 |
+
PAAS_BASE_URL:
|
| 734 |
+
title: PaaS base url
|
| 735 |
+
type: string
|
| 736 |
+
scope: global
|
| 737 |
+
inputs:
|
| 738 |
+
image:
|
| 739 |
+
order: 1
|
| 740 |
+
title: Image
|
| 741 |
+
type: image
|
| 742 |
+
required: true
|
| 743 |
+
upscalingResize:
|
| 744 |
+
order: 2
|
| 745 |
+
title: Resize
|
| 746 |
+
type: float
|
| 747 |
+
required: true
|
| 748 |
+
min: 0.1
|
| 749 |
+
max: 4
|
| 750 |
+
step: 0.1
|
| 751 |
+
default: 2
|
| 752 |
+
outputs:
|
| 753 |
+
image:
|
| 754 |
+
title: Image
|
| 755 |
+
type: image
|
| 756 |
+
package: artworks
|
| 757 |
+
source: catalog
|
| 758 |
+
title: en=Upscale image;ru=Увеличить изображение
|
| 759 |
+
version: 1
|
| 760 |
+
script: |-
|
| 761 |
+
const CHECK_TASK_INTERVAL = 3000;
|
| 762 |
+
const MAX_ATTEMPTS = 20;
|
| 763 |
+
|
| 764 |
+
export async function run({ inputs, state }) {
|
| 765 |
+
|
| 766 |
+
const { FatalError, TimeoutError, RepeatNode, NextNode } = DEFINITIONS;
|
| 767 |
+
const { ArtWorks, FatalError: ArtWorksError } = require('artworks');
|
| 768 |
+
|
| 769 |
+
const PAAS_BASE_URL = env.variables.get('PAAS_BASE_URL');
|
| 770 |
+
if (!PAAS_BASE_URL) {
|
| 771 |
+
throw new FatalError('Please, set PAAS_BASE_URL in environment');
|
| 772 |
+
}
|
| 773 |
+
const OPEN_PAAS_USER = env.variables.get('OPEN_PAAS_USER');
|
| 774 |
+
if (!OPEN_PAAS_USER) {
|
| 775 |
+
throw new FatalError('Please, set OPEN_PAAS_USER in environment');
|
| 776 |
+
}
|
| 777 |
+
const OPEN_PAAS_PASSWORD = env.variables.get('OPEN_PAAS_PASSWORD');
|
| 778 |
+
if (!OPEN_PAAS_PASSWORD) {
|
| 779 |
+
throw new FatalError('Please, set OPEN_PAAS_PASSWORD in environment');
|
| 780 |
+
}
|
| 781 |
+
|
| 782 |
+
const artworks = new ArtWorks({
|
| 783 |
+
baseUrl: PAAS_BASE_URL,
|
| 784 |
+
username: OPEN_PAAS_USER,
|
| 785 |
+
password: OPEN_PAAS_PASSWORD
|
| 786 |
+
});
|
| 787 |
+
|
| 788 |
+
if (!state) {
|
| 789 |
+
const {
|
| 790 |
+
image,
|
| 791 |
+
upscalingResize,
|
| 792 |
+
} = inputs;
|
| 793 |
+
|
| 794 |
+
const payload = {
|
| 795 |
+
type: "upscale-image",
|
| 796 |
+
isFast: true,
|
| 797 |
+
payload: {
|
| 798 |
+
base64: false,
|
| 799 |
+
image,
|
| 800 |
+
upscalingResize,
|
| 801 |
+
},
|
| 802 |
+
};
|
| 803 |
+
try {
|
| 804 |
+
const task = await artworks.createTask(payload);
|
| 805 |
+
console.log(`Task created ${task}`);
|
| 806 |
+
return RepeatNode.from({
|
| 807 |
+
state: {
|
| 808 |
+
payload,
|
| 809 |
+
task,
|
| 810 |
+
attempt: 0,
|
| 811 |
+
startedAt: new Date()
|
| 812 |
+
},
|
| 813 |
+
progress: {
|
| 814 |
+
total: MAX_ATTEMPTS,
|
| 815 |
+
processed: 0
|
| 816 |
+
},
|
| 817 |
+
delay: 5000
|
| 818 |
+
});
|
| 819 |
+
} catch (e) {
|
| 820 |
+
if (e instanceof ArtWorksError) {
|
| 821 |
+
throw new FatalError(e.message);
|
| 822 |
+
}
|
| 823 |
+
throw e;
|
| 824 |
+
}
|
| 825 |
+
} else {
|
| 826 |
+
const {
|
| 827 |
+
payload,
|
| 828 |
+
task,
|
| 829 |
+
attempt,
|
| 830 |
+
startedAt
|
| 831 |
+
} = state;
|
| 832 |
+
|
| 833 |
+
if (attempt > MAX_ATTEMPTS) {
|
| 834 |
+
try {
|
| 835 |
+
await artworks.cancelTask(task);
|
| 836 |
+
} catch (e) { }
|
| 837 |
+
|
| 838 |
+
const now = new Date();
|
| 839 |
+
const time = (now - new Date(startedAt)) / 1000;
|
| 840 |
+
throw new TimeoutError(`PaaS task for text to image ${task} timeout in ${time} sec`);
|
| 841 |
+
}
|
| 842 |
+
|
| 843 |
+
console.log(`Check task ${attempt} ${task}`);
|
| 844 |
+
|
| 845 |
+
try {
|
| 846 |
+
const results = await artworks.checkState(task);
|
| 847 |
+
if (!results) {
|
| 848 |
+
return RepeatNode.from({
|
| 849 |
+
delay: CHECK_TASK_INTERVAL,
|
| 850 |
+
state: {
|
| 851 |
+
payload,
|
| 852 |
+
task,
|
| 853 |
+
attempt: attempt + 1,
|
| 854 |
+
startedAt,
|
| 855 |
+
},
|
| 856 |
+
progress: {
|
| 857 |
+
total: MAX_ATTEMPTS,
|
| 858 |
+
processed: attempt
|
| 859 |
+
},
|
| 860 |
+
});
|
| 861 |
+
}
|
| 862 |
+
let { image: { url: image } } = results;
|
| 863 |
+
return NextNode.from({
|
| 864 |
+
outputs: {
|
| 865 |
+
image
|
| 866 |
+
}
|
| 867 |
+
});
|
| 868 |
+
} catch (e) {
|
| 869 |
+
if (e instanceof ArtWorksError) {
|
| 870 |
+
throw new FatalError(e.message);
|
| 871 |
+
}
|
| 872 |
+
throw e;
|
| 873 |
+
}
|
| 874 |
+
}
|
| 875 |
+
}
|
| 876 |
+
exctract_mask_on_image:
|
| 877 |
+
_id: exctract_mask_on_image
|
| 878 |
+
arrange:
|
| 879 |
+
x: 900
|
| 880 |
+
y: 50
|
| 881 |
+
category:
|
| 882 |
+
id: image_analysis
|
| 883 |
+
title: en=Image analysis;ru=Анализ изображений
|
| 884 |
+
environment:
|
| 885 |
+
OPEN_PAAS_USER:
|
| 886 |
+
title: PaaS user
|
| 887 |
+
type: string
|
| 888 |
+
scope: global
|
| 889 |
+
OPEN_PAAS_PASSWORD:
|
| 890 |
+
title: PaaS password
|
| 891 |
+
type: string
|
| 892 |
+
scope: global
|
| 893 |
+
PAAS_BASE_URL:
|
| 894 |
+
title: PaaS base url
|
| 895 |
+
type: string
|
| 896 |
+
scope: global
|
| 897 |
+
inputs:
|
| 898 |
+
image:
|
| 899 |
+
order: 1
|
| 900 |
+
title: Image
|
| 901 |
+
type: image
|
| 902 |
+
required: true
|
| 903 |
+
type:
|
| 904 |
+
order: 2
|
| 905 |
+
title: Type
|
| 906 |
+
type: string
|
| 907 |
+
required: true
|
| 908 |
+
default: yolo
|
| 909 |
+
enum:
|
| 910 |
+
- yolo|Yolo
|
| 911 |
+
- default|Prompt
|
| 912 |
+
prompt:
|
| 913 |
+
order: 4
|
| 914 |
+
title: Prompt
|
| 915 |
+
type: string
|
| 916 |
+
required: false
|
| 917 |
+
multiline: true
|
| 918 |
+
model:
|
| 919 |
+
order: 3
|
| 920 |
+
title: Yolo model
|
| 921 |
+
type: string
|
| 922 |
+
required: false
|
| 923 |
+
default: deepfashion2_yolov8s-seg.pt
|
| 924 |
+
enum:
|
| 925 |
+
- deepfashion2_yolov8s-seg.pt
|
| 926 |
+
- face_yolov8m.pt
|
| 927 |
+
- face_yolov8n.pt
|
| 928 |
+
- face_yolov8s.pt
|
| 929 |
+
- female_breast_v3.2.pt
|
| 930 |
+
- hand_yolov8n.pt
|
| 931 |
+
- hand_yolov8s.pt
|
| 932 |
+
- penisV2.pt
|
| 933 |
+
- person_yolov8m-seg.pt
|
| 934 |
+
- person_yolov8n-seg.pt
|
| 935 |
+
- person_yolov8s-seg.pt
|
| 936 |
+
- vagina-v2.6.pt
|
| 937 |
+
threshold:
|
| 938 |
+
order: 5
|
| 939 |
+
title: Threshold
|
| 940 |
+
type: float
|
| 941 |
+
required: true
|
| 942 |
+
min: 0.1
|
| 943 |
+
max: 0.69
|
| 944 |
+
step: 0.1
|
| 945 |
+
default: 0.5
|
| 946 |
+
confidence:
|
| 947 |
+
order: 6
|
| 948 |
+
title: Confidence
|
| 949 |
+
type: float
|
| 950 |
+
required: true
|
| 951 |
+
min: 0.1
|
| 952 |
+
max: 0.99
|
| 953 |
+
step: 0.1
|
| 954 |
+
default: 0.5
|
| 955 |
+
applyConvexHull:
|
| 956 |
+
order: 8
|
| 957 |
+
title: Apply convex hull
|
| 958 |
+
type: boolean
|
| 959 |
+
default: false
|
| 960 |
+
outputs:
|
| 961 |
+
merged:
|
| 962 |
+
title: Merged
|
| 963 |
+
type: image
|
| 964 |
+
masks:
|
| 965 |
+
title: Masks
|
| 966 |
+
type: json
|
| 967 |
+
schema: image-masks
|
| 968 |
+
package: artworks
|
| 969 |
+
script: |-
|
| 970 |
+
const CHECK_TASK_INTERVAL = 3000;
|
| 971 |
+
const MAX_ATTEMPTS = 20;
|
| 972 |
+
|
| 973 |
+
export async function run({ inputs, state }) {
|
| 974 |
+
|
| 975 |
+
const { FatalError, TimeoutError, RepeatNode, NextNode } = DEFINITIONS;
|
| 976 |
+
const { ArtWorks, FatalError: ArtWorksError } = require('artworks');
|
| 977 |
+
const sharp = require('sharp/lib/index.js');
|
| 978 |
+
|
| 979 |
+
const PAAS_BASE_URL = env.variables.get('PAAS_BASE_URL');
|
| 980 |
+
if (!PAAS_BASE_URL) {
|
| 981 |
+
throw new FatalError('Please, set PAAS_BASE_URL in environment');
|
| 982 |
+
}
|
| 983 |
+
const OPEN_PAAS_USER = env.variables.get('OPEN_PAAS_USER');
|
| 984 |
+
if (!OPEN_PAAS_USER) {
|
| 985 |
+
throw new FatalError('Please, set OPEN_PAAS_USER in environment');
|
| 986 |
+
}
|
| 987 |
+
const OPEN_PAAS_PASSWORD = env.variables.get('OPEN_PAAS_PASSWORD');
|
| 988 |
+
if (!OPEN_PAAS_PASSWORD) {
|
| 989 |
+
throw new FatalError('Please, set OPEN_PAAS_PASSWORD in environment');
|
| 990 |
+
}
|
| 991 |
+
|
| 992 |
+
const artworks = new ArtWorks({
|
| 993 |
+
baseUrl: PAAS_BASE_URL,
|
| 994 |
+
username: OPEN_PAAS_USER,
|
| 995 |
+
password: OPEN_PAAS_PASSWORD
|
| 996 |
+
});
|
| 997 |
+
|
| 998 |
+
if (!state) {
|
| 999 |
+
const { image, type, model, prompt, threshold, applyConvexHull } = inputs;
|
| 1000 |
+
|
| 1001 |
+
const payload = {
|
| 1002 |
+
type: "image-to-mask",
|
| 1003 |
+
isFast: true,
|
| 1004 |
+
payload: {
|
| 1005 |
+
base64: false,
|
| 1006 |
+
image,
|
| 1007 |
+
type,
|
| 1008 |
+
model,
|
| 1009 |
+
prompt,
|
| 1010 |
+
threshold,
|
| 1011 |
+
applyConvexHull,
|
| 1012 |
+
},
|
| 1013 |
+
};
|
| 1014 |
+
try {
|
| 1015 |
+
const task = await artworks.createTask(payload);
|
| 1016 |
+
console.log(`Task created ${task}`);
|
| 1017 |
+
return RepeatNode.from({
|
| 1018 |
+
state: {
|
| 1019 |
+
payload,
|
| 1020 |
+
task,
|
| 1021 |
+
attempt: 0,
|
| 1022 |
+
startedAt: new Date()
|
| 1023 |
+
},
|
| 1024 |
+
progress: {
|
| 1025 |
+
total: MAX_ATTEMPTS,
|
| 1026 |
+
processed: 0
|
| 1027 |
+
},
|
| 1028 |
+
delay: 5000
|
| 1029 |
+
});
|
| 1030 |
+
} catch (e) {
|
| 1031 |
+
if (e instanceof ArtWorksError) {
|
| 1032 |
+
throw new FatalError(e.message);
|
| 1033 |
+
}
|
| 1034 |
+
throw e;
|
| 1035 |
+
}
|
| 1036 |
+
} else {
|
| 1037 |
+
const {
|
| 1038 |
+
payload,
|
| 1039 |
+
task,
|
| 1040 |
+
attempt,
|
| 1041 |
+
startedAt
|
| 1042 |
+
} = state;
|
| 1043 |
+
|
| 1044 |
+
if (attempt > MAX_ATTEMPTS) {
|
| 1045 |
+
try {
|
| 1046 |
+
await artworks.cancelTask(task);
|
| 1047 |
+
} catch (e) { }
|
| 1048 |
+
|
| 1049 |
+
const now = new Date();
|
| 1050 |
+
const time = (now - new Date(startedAt)) / 1000;
|
| 1051 |
+
throw new TimeoutError(`PaaS task for text to image ${task} timeout in ${time} sec`);
|
| 1052 |
+
}
|
| 1053 |
+
|
| 1054 |
+
console.log(`Check task ${attempt} ${task}`);
|
| 1055 |
+
|
| 1056 |
+
try {
|
| 1057 |
+
const results = await artworks.checkState(task);
|
| 1058 |
+
if (!results) {
|
| 1059 |
+
return RepeatNode.from({
|
| 1060 |
+
delay: CHECK_TASK_INTERVAL,
|
| 1061 |
+
state: {
|
| 1062 |
+
payload,
|
| 1063 |
+
task,
|
| 1064 |
+
attempt: attempt + 1,
|
| 1065 |
+
startedAt,
|
| 1066 |
+
},
|
| 1067 |
+
progress: {
|
| 1068 |
+
total: MAX_ATTEMPTS,
|
| 1069 |
+
processed: attempt
|
| 1070 |
+
},
|
| 1071 |
+
});
|
| 1072 |
+
}
|
| 1073 |
+
const { masks: detected } = results;
|
| 1074 |
+
const { image } = inputs;
|
| 1075 |
+
const { data } = await download(image);
|
| 1076 |
+
const { width, height } = await sharp(data).metadata();
|
| 1077 |
+
|
| 1078 |
+
const areas = [];
|
| 1079 |
+
const masks = [];
|
| 1080 |
+
for (const m of detected) {
|
| 1081 |
+
const {
|
| 1082 |
+
mask,
|
| 1083 |
+
confidence,
|
| 1084 |
+
className,
|
| 1085 |
+
coordinates: [left, top],
|
| 1086 |
+
} = m;
|
| 1087 |
+
|
| 1088 |
+
const buffer = Buffer.from(mask, "base64");
|
| 1089 |
+
|
| 1090 |
+
areas.push({
|
| 1091 |
+
input: buffer,
|
| 1092 |
+
top,
|
| 1093 |
+
left,
|
| 1094 |
+
});
|
| 1095 |
+
|
| 1096 |
+
const { width, height } = await sharp(buffer).metadata();
|
| 1097 |
+
masks.push({
|
| 1098 |
+
top,
|
| 1099 |
+
left,
|
| 1100 |
+
width,
|
| 1101 |
+
height,
|
| 1102 |
+
className,
|
| 1103 |
+
confidence,
|
| 1104 |
+
});
|
| 1105 |
+
}
|
| 1106 |
+
|
| 1107 |
+
let merged = await sharp({
|
| 1108 |
+
create: {
|
| 1109 |
+
width,
|
| 1110 |
+
height,
|
| 1111 |
+
channels: 3,
|
| 1112 |
+
background: { r: 0, g: 0, b: 0 },
|
| 1113 |
+
},
|
| 1114 |
+
}).composite(areas);
|
| 1115 |
+
return NextNode.from({
|
| 1116 |
+
outputs: {
|
| 1117 |
+
masks,
|
| 1118 |
+
merged: await merged.png().toBuffer()
|
| 1119 |
+
}
|
| 1120 |
+
});
|
| 1121 |
+
} catch (e) {
|
| 1122 |
+
if (e instanceof ArtWorksError) {
|
| 1123 |
+
throw new FatalError(e.message);
|
| 1124 |
+
}
|
| 1125 |
+
throw e;
|
| 1126 |
+
}
|
| 1127 |
+
}
|
| 1128 |
+
}
|
| 1129 |
+
source: catalog
|
| 1130 |
+
title: en=Extract mask on image;ru=Выделить маску
|
| 1131 |
+
version: 1
|
| 1132 |
+
classify_image:
|
| 1133 |
+
_id: classify_image
|
| 1134 |
+
arrange:
|
| 1135 |
+
x: 1080
|
| 1136 |
+
y: 460
|
| 1137 |
+
category:
|
| 1138 |
+
id: image_analysis
|
| 1139 |
+
title: en=Image analysis;ru=Анализ изображений
|
| 1140 |
+
environment:
|
| 1141 |
+
OPEN_PAAS_USER:
|
| 1142 |
+
title: PaaS user
|
| 1143 |
+
type: string
|
| 1144 |
+
scope: global
|
| 1145 |
+
OPEN_PAAS_PASSWORD:
|
| 1146 |
+
title: PaaS password
|
| 1147 |
+
type: string
|
| 1148 |
+
scope: global
|
| 1149 |
+
PAAS_BASE_URL:
|
| 1150 |
+
title: PaaS base url
|
| 1151 |
+
type: string
|
| 1152 |
+
scope: global
|
| 1153 |
+
inputs:
|
| 1154 |
+
image:
|
| 1155 |
+
order: 1
|
| 1156 |
+
title: Image
|
| 1157 |
+
type: image
|
| 1158 |
+
required: true
|
| 1159 |
+
labels:
|
| 1160 |
+
order: 2
|
| 1161 |
+
title: Labels
|
| 1162 |
+
type: json
|
| 1163 |
+
required: true
|
| 1164 |
+
default: '{ "girl": "girl on photo", "male": "male on photo" }'
|
| 1165 |
+
schema:
|
| 1166 |
+
id: image-labels
|
| 1167 |
+
outputs:
|
| 1168 |
+
labels:
|
| 1169 |
+
title: Labels
|
| 1170 |
+
type: json
|
| 1171 |
+
package: artworks
|
| 1172 |
+
script: |-
|
| 1173 |
+
const CHECK_TASK_INTERVAL = 1000;
|
| 1174 |
+
const MAX_ATTEMPTS = 20;
|
| 1175 |
+
|
| 1176 |
+
export async function run({ inputs, state }) {
|
| 1177 |
+
|
| 1178 |
+
const { FatalError, TimeoutError, RepeatNode, NextNode } = DEFINITIONS;
|
| 1179 |
+
const { ArtWorks, FatalError: ArtWorksError } = require('artworks');
|
| 1180 |
+
|
| 1181 |
+
const PAAS_BASE_URL = env.variables.get('PAAS_BASE_URL');
|
| 1182 |
+
if (!PAAS_BASE_URL) {
|
| 1183 |
+
throw new FatalError('Please, set PAAS_BASE_URL in environment');
|
| 1184 |
+
}
|
| 1185 |
+
const OPEN_PAAS_USER = env.variables.get('OPEN_PAAS_USER');
|
| 1186 |
+
if (!OPEN_PAAS_USER) {
|
| 1187 |
+
throw new FatalError('Please, set OPEN_PAAS_USER in environment');
|
| 1188 |
+
}
|
| 1189 |
+
const OPEN_PAAS_PASSWORD = env.variables.get('OPEN_PAAS_PASSWORD');
|
| 1190 |
+
if (!OPEN_PAAS_PASSWORD) {
|
| 1191 |
+
throw new FatalError('Please, set OPEN_PAAS_PASSWORD in environment');
|
| 1192 |
+
}
|
| 1193 |
+
|
| 1194 |
+
const artworks = new ArtWorks({
|
| 1195 |
+
baseUrl: PAAS_BASE_URL,
|
| 1196 |
+
username: OPEN_PAAS_USER,
|
| 1197 |
+
password: OPEN_PAAS_PASSWORD
|
| 1198 |
+
});
|
| 1199 |
+
|
| 1200 |
+
if (!state) {
|
| 1201 |
+
const { image, labels } = inputs;
|
| 1202 |
+
|
| 1203 |
+
const payload = {
|
| 1204 |
+
type: "classify-image",
|
| 1205 |
+
isFast: true,
|
| 1206 |
+
payload: {
|
| 1207 |
+
base64: false,
|
| 1208 |
+
image,
|
| 1209 |
+
labels: Object.values(labels),
|
| 1210 |
+
},
|
| 1211 |
+
};
|
| 1212 |
+
try {
|
| 1213 |
+
const task = await artworks.createTask(payload);
|
| 1214 |
+
console.log(`Task created ${task}`);
|
| 1215 |
+
return RepeatNode.from({
|
| 1216 |
+
state: {
|
| 1217 |
+
payload,
|
| 1218 |
+
task,
|
| 1219 |
+
attempt: 0,
|
| 1220 |
+
startedAt: new Date()
|
| 1221 |
+
},
|
| 1222 |
+
progress: {
|
| 1223 |
+
total: MAX_ATTEMPTS,
|
| 1224 |
+
processed: 0
|
| 1225 |
+
},
|
| 1226 |
+
delay: 2000
|
| 1227 |
+
});
|
| 1228 |
+
} catch (e) {
|
| 1229 |
+
if (e instanceof ArtWorksError) {
|
| 1230 |
+
throw new FatalError(e.message);
|
| 1231 |
+
}
|
| 1232 |
+
throw e;
|
| 1233 |
+
}
|
| 1234 |
+
} else {
|
| 1235 |
+
const {
|
| 1236 |
+
payload,
|
| 1237 |
+
task,
|
| 1238 |
+
attempt,
|
| 1239 |
+
startedAt
|
| 1240 |
+
} = state;
|
| 1241 |
+
|
| 1242 |
+
if (attempt > MAX_ATTEMPTS) {
|
| 1243 |
+
try {
|
| 1244 |
+
await artworks.cancelTask(task);
|
| 1245 |
+
} catch (e) { }
|
| 1246 |
+
|
| 1247 |
+
const now = new Date();
|
| 1248 |
+
const time = (now - new Date(startedAt)) / 1000;
|
| 1249 |
+
throw new TimeoutError(`PaaS task for text to image ${task} timeout in ${time} sec`);
|
| 1250 |
+
}
|
| 1251 |
+
|
| 1252 |
+
console.log(`Check task ${attempt} ${task}`);
|
| 1253 |
+
|
| 1254 |
+
try {
|
| 1255 |
+
const results = await artworks.checkState(task);
|
| 1256 |
+
if (!results) {
|
| 1257 |
+
return RepeatNode.from({
|
| 1258 |
+
delay: CHECK_TASK_INTERVAL,
|
| 1259 |
+
state: {
|
| 1260 |
+
payload,
|
| 1261 |
+
task,
|
| 1262 |
+
attempt: attempt + 1,
|
| 1263 |
+
startedAt,
|
| 1264 |
+
},
|
| 1265 |
+
progress: {
|
| 1266 |
+
total: MAX_ATTEMPTS,
|
| 1267 |
+
processed: attempt
|
| 1268 |
+
},
|
| 1269 |
+
});
|
| 1270 |
+
}
|
| 1271 |
+
let { probs } = results;
|
| 1272 |
+
const { labels } = inputs;
|
| 1273 |
+
const tags = {};
|
| 1274 |
+
for (const key of Object.keys(labels)) {
|
| 1275 |
+
tags[key] = probs[labels[key]];
|
| 1276 |
+
}
|
| 1277 |
+
return NextNode.from({
|
| 1278 |
+
outputs: {
|
| 1279 |
+
labels: tags
|
| 1280 |
+
}
|
| 1281 |
+
});
|
| 1282 |
+
} catch (e) {
|
| 1283 |
+
if (e instanceof ArtWorksError) {
|
| 1284 |
+
throw new FatalError(e.message);
|
| 1285 |
+
}
|
| 1286 |
+
throw e;
|
| 1287 |
+
}
|
| 1288 |
+
}
|
| 1289 |
+
}
|
| 1290 |
+
source: catalog
|
| 1291 |
+
title: en=Classify image;ru=Тегировать изображение
|
| 1292 |
+
version: 1
|
| 1293 |
+
detect_face_on_image:
|
| 1294 |
+
_id: detect_face_on_image
|
| 1295 |
+
arrange:
|
| 1296 |
+
x: 900
|
| 1297 |
+
y: 330
|
| 1298 |
+
category:
|
| 1299 |
+
id: image_analysis
|
| 1300 |
title: en=Image analysis;ru=Анализ изображений
|
| 1301 |
environment:
|
| 1302 |
OPEN_PAAS_USER:
|
|
|
|
| 1317 |
title: en=Image;ru=Изображение
|
| 1318 |
type: image
|
| 1319 |
required: true
|
| 1320 |
+
index:
|
| 1321 |
order: 2
|
| 1322 |
+
title: en=Index;ru=Индекс
|
| 1323 |
+
type: integer
|
| 1324 |
required: true
|
| 1325 |
+
default: 0
|
|
|
|
|
|
|
|
|
|
| 1326 |
outputs:
|
| 1327 |
+
face:
|
| 1328 |
+
title: en=Face;ru=Лицо
|
| 1329 |
type: image
|
| 1330 |
+
features:
|
| 1331 |
+
title: en=Features;ru=Характеристики
|
| 1332 |
+
type: json
|
| 1333 |
+
schema: face-features
|
| 1334 |
package: artworks
|
| 1335 |
+
script: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1336 |
const CHECK_TASK_INTERVAL = 3000;
|
| 1337 |
+
const MAX_ATTEMPTS = 10;
|
| 1338 |
|
| 1339 |
+
const FIT_FACE_SIZE = 512;
|
|
|
|
|
|
|
| 1340 |
|
| 1341 |
+
export async function fit(image, { maxWidth, maxHeight }) {
|
| 1342 |
+
const { width, height } = await image.metadata();
|
| 1343 |
+
const orientation = width >= height ? "-" : "|";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1344 |
|
| 1345 |
+
const sharp = require('sharp/lib/index.js');
|
| 1346 |
+
|
| 1347 |
+
switch (orientation) {
|
| 1348 |
+
case "-":
|
| 1349 |
+
if (width > maxWidth) {
|
| 1350 |
+
return sharp(await image.resize({ width: maxWidth }).toBuffer());
|
| 1351 |
+
}
|
| 1352 |
+
break;
|
| 1353 |
+
case "|":
|
| 1354 |
+
if (height > maxHeight) {
|
| 1355 |
+
return sharp(await image.resize({ height: maxHeight }).toBuffer());
|
| 1356 |
+
}
|
| 1357 |
+
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1358 |
}
|
| 1359 |
+
|
| 1360 |
+
return image;
|
| 1361 |
}
|
| 1362 |
|
| 1363 |
+
export async function crop(source, face) {
|
| 1364 |
+
const sharp = require('sharp/lib/index.js');
|
| 1365 |
+
|
| 1366 |
+
const image = await sharp(source);
|
| 1367 |
+
const metadata = await image.metadata();
|
| 1368 |
+
|
| 1369 |
+
const UNCROP = 0.6;
|
| 1370 |
+
|
| 1371 |
+
let { x, y, width, height } = face;
|
| 1372 |
+
|
| 1373 |
+
const uncropX = width * UNCROP;
|
| 1374 |
+
const uncropY = height * UNCROP;
|
| 1375 |
+
|
| 1376 |
+
width = Math.round(width + uncropX);
|
| 1377 |
+
height = Math.round(height + uncropY);
|
| 1378 |
+
x = Math.round(x - uncropX / 2);
|
| 1379 |
+
y = Math.round(y - uncropY / 2);
|
| 1380 |
+
|
| 1381 |
+
const [left, top] = [Math.max(x, 0), Math.max(y, 0)];
|
| 1382 |
+
[width, height] = [
|
| 1383 |
+
Math.min(width, metadata.width - left),
|
| 1384 |
+
Math.min(height, metadata.height - top),
|
| 1385 |
+
];
|
| 1386 |
+
const size = Math.min(width, height);
|
| 1387 |
+
|
| 1388 |
+
const crop = {
|
| 1389 |
+
left,
|
| 1390 |
+
top,
|
| 1391 |
+
width: size,
|
| 1392 |
+
height: size,
|
| 1393 |
+
};
|
| 1394 |
+
|
| 1395 |
+
const area = await fit(await image.clone().extract(crop).webp(), {
|
| 1396 |
+
maxWidth: FIT_FACE_SIZE,
|
| 1397 |
+
maxHeight: FIT_FACE_SIZE,
|
| 1398 |
});
|
| 1399 |
|
| 1400 |
+
return area.toBuffer();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1401 |
}
|
| 1402 |
|
| 1403 |
+
export async function run({ inputs, state }) {
|
| 1404 |
+
|
| 1405 |
+
const { FatalError, TimeoutError, RepeatNode, NextNode } = DEFINITIONS;
|
| 1406 |
+
const { ArtWorks, FatalError: ArtWorksError } = require('artworks');
|
| 1407 |
+
|
| 1408 |
+
const PAAS_BASE_URL = env.variables.get('PAAS_BASE_URL');
|
| 1409 |
+
if (!PAAS_BASE_URL) {
|
| 1410 |
+
throw new FatalError('Please, set PAAS_BASE_URL in environment');
|
| 1411 |
+
}
|
| 1412 |
+
const OPEN_PAAS_USER = env.variables.get('OPEN_PAAS_USER');
|
| 1413 |
+
if (!OPEN_PAAS_USER) {
|
| 1414 |
+
throw new FatalError('Please, set OPEN_PAAS_USER in environment');
|
| 1415 |
+
}
|
| 1416 |
+
const OPEN_PAAS_PASSWORD = env.variables.get('OPEN_PAAS_PASSWORD');
|
| 1417 |
+
if (!OPEN_PAAS_PASSWORD) {
|
| 1418 |
+
throw new FatalError('Please, set OPEN_PAAS_PASSWORD in environment');
|
| 1419 |
+
}
|
| 1420 |
|
| 1421 |
+
const artworks = new ArtWorks({
|
| 1422 |
+
baseUrl: PAAS_BASE_URL,
|
| 1423 |
+
username: OPEN_PAAS_USER,
|
| 1424 |
+
password: OPEN_PAAS_PASSWORD
|
| 1425 |
+
});
|
| 1426 |
|
| 1427 |
if (!state) {
|
| 1428 |
+
const { image, index } = inputs;
|
| 1429 |
+
|
| 1430 |
const payload = {
|
| 1431 |
+
type: "detect-faces",
|
| 1432 |
isFast: true,
|
| 1433 |
payload: {
|
| 1434 |
base64: false,
|
|
|
|
| 1435 |
image,
|
| 1436 |
+
features: ["age", "gender", "race", "emotion"],
|
| 1437 |
},
|
| 1438 |
};
|
| 1439 |
+
try {
|
| 1440 |
+
const task = await artworks.createTask(payload);
|
| 1441 |
+
console.log(`Task created ${task}`);
|
| 1442 |
+
return RepeatNode.from({
|
| 1443 |
+
state: {
|
| 1444 |
+
payload,
|
| 1445 |
+
task,
|
| 1446 |
+
attempt: 0,
|
| 1447 |
+
startedAt: new Date()
|
| 1448 |
+
},
|
| 1449 |
+
progress: {
|
| 1450 |
+
total: MAX_ATTEMPTS,
|
| 1451 |
+
processed: 0
|
| 1452 |
+
},
|
| 1453 |
+
delay: 2000
|
| 1454 |
+
});
|
| 1455 |
+
} catch (e) {
|
| 1456 |
+
if (e instanceof ArtWorksError) {
|
| 1457 |
+
throw new FatalError(e.message);
|
| 1458 |
+
}
|
| 1459 |
+
throw e;
|
| 1460 |
+
}
|
| 1461 |
} else {
|
| 1462 |
const {
|
| 1463 |
payload,
|
|
|
|
| 1465 |
attempt,
|
| 1466 |
startedAt
|
| 1467 |
} = state;
|
| 1468 |
+
|
| 1469 |
+
if (attempt > MAX_ATTEMPTS) {
|
| 1470 |
+
try {
|
| 1471 |
+
await artworks.cancelTask(task);
|
| 1472 |
+
} catch (e) { }
|
| 1473 |
|
| 1474 |
const now = new Date();
|
| 1475 |
const time = (now - new Date(startedAt)) / 1000;
|
| 1476 |
+
throw new TimeoutError(`PaaS task for text to image ${task} timeout in ${time} sec`);
|
| 1477 |
}
|
| 1478 |
|
| 1479 |
+
console.log(`Check task ${attempt} ${task}`);
|
| 1480 |
+
|
| 1481 |
+
try {
|
| 1482 |
+
const results = await artworks.checkState(task);
|
| 1483 |
+
if (!results) {
|
| 1484 |
+
return RepeatNode.from({
|
| 1485 |
+
delay: CHECK_TASK_INTERVAL,
|
| 1486 |
+
state: {
|
| 1487 |
+
payload,
|
| 1488 |
+
task,
|
| 1489 |
+
attempt: attempt + 1,
|
| 1490 |
+
startedAt,
|
| 1491 |
+
},
|
| 1492 |
+
progress: {
|
| 1493 |
+
total: MAX_ATTEMPTS,
|
| 1494 |
+
processed: attempt
|
| 1495 |
+
},
|
| 1496 |
+
});
|
| 1497 |
+
}
|
| 1498 |
+
const { faces } = results;
|
| 1499 |
+
const { image, index } = inputs;
|
| 1500 |
+
const face = faces[index];
|
| 1501 |
+
if (!face) {
|
| 1502 |
+
throw new FatalError("Face with such index was not found");
|
| 1503 |
+
}
|
| 1504 |
+
const { x, y, width, height, ageFrom, ageTo, gender, race, emotion } = face;
|
| 1505 |
+
const { data } = await download(image);
|
| 1506 |
+
return NextNode.from({
|
| 1507 |
+
outputs: {
|
| 1508 |
+
face: await crop(data, {
|
| 1509 |
+
x,
|
| 1510 |
+
y,
|
| 1511 |
+
width,
|
| 1512 |
+
height,
|
| 1513 |
+
}),
|
| 1514 |
+
features: {
|
| 1515 |
+
ageFrom,
|
| 1516 |
+
ageTo,
|
| 1517 |
+
gender,
|
| 1518 |
+
race,
|
| 1519 |
+
emotion,
|
| 1520 |
+
},
|
| 1521 |
},
|
| 1522 |
});
|
| 1523 |
+
} catch (e) {
|
| 1524 |
+
if (e instanceof ArtWorksError) {
|
| 1525 |
+
throw new FatalError(e.message);
|
|
|
|
|
|
|
| 1526 |
}
|
| 1527 |
+
throw e;
|
| 1528 |
+
}
|
| 1529 |
}
|
| 1530 |
+
}
|
|
|
|
| 1531 |
source: catalog
|
| 1532 |
+
title: en=Detect face;ru=Определить лицо
|
| 1533 |
version: 1
|
| 1534 |
+
remove_background:
|
| 1535 |
+
_id: remove_background
|
| 1536 |
arrange:
|
| 1537 |
+
x: 750
|
| 1538 |
+
y: 630
|
| 1539 |
category:
|
| 1540 |
+
id: image_processing
|
| 1541 |
+
title: en=Work with images;ru=Работа с изображениями
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1542 |
environment:
|
| 1543 |
OPEN_PAAS_USER:
|
| 1544 |
title: PaaS user
|
|
|
|
| 1552 |
title: PaaS base url
|
| 1553 |
type: string
|
| 1554 |
scope: global
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1555 |
inputs:
|
| 1556 |
+
image:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1557 |
order: 1
|
| 1558 |
+
title: en=Image;ru=Изображение
|
| 1559 |
+
type: image
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1560 |
required: true
|
| 1561 |
+
model:
|
| 1562 |
+
order: 2
|
| 1563 |
+
title: en=Model;ru=Модель
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1570 |
outputs:
|
| 1571 |
image:
|
| 1572 |
+
title: en=Image;ru=Изображение
|
| 1573 |
type: image
|
|
|
|
|
|
|
|
|
|
| 1574 |
package: artworks
|
| 1575 |
script: |-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1576 |
const CHECK_TASK_INTERVAL = 3000;
|
| 1577 |
+
const MAX_ATTEMPTS = 20;
|
| 1578 |
|
| 1579 |
+
export async function run({ inputs, state }) {
|
|
|
|
|
|
|
| 1580 |
|
| 1581 |
+
const { FatalError, TimeoutError, RepeatNode, NextNode } = DEFINITIONS;
|
| 1582 |
+
const { ArtWorks, FatalError: ArtWorksError } = require('artworks');
|
| 1583 |
|
| 1584 |
+
const PAAS_BASE_URL = env.variables.get('PAAS_BASE_URL');
|
| 1585 |
+
if (!PAAS_BASE_URL) {
|
| 1586 |
+
throw new FatalError('Please, set PAAS_BASE_URL in environment');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1587 |
}
|
| 1588 |
+
const OPEN_PAAS_USER = env.variables.get('OPEN_PAAS_USER');
|
| 1589 |
+
if (!OPEN_PAAS_USER) {
|
| 1590 |
+
throw new FatalError('Please, set OPEN_PAAS_USER in environment');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1591 |
}
|
| 1592 |
+
const OPEN_PAAS_PASSWORD = env.variables.get('OPEN_PAAS_PASSWORD');
|
| 1593 |
+
if (!OPEN_PAAS_PASSWORD) {
|
| 1594 |
+
throw new FatalError('Please, set OPEN_PAAS_PASSWORD in environment');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1595 |
}
|
|
|
|
| 1596 |
|
| 1597 |
+
const artworks = new ArtWorks({
|
| 1598 |
+
baseUrl: PAAS_BASE_URL,
|
| 1599 |
+
username: OPEN_PAAS_USER,
|
| 1600 |
+
password: OPEN_PAAS_PASSWORD
|
| 1601 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1602 |
|
| 1603 |
if (!state) {
|
| 1604 |
+
const {
|
| 1605 |
+
image,
|
| 1606 |
+
model,
|
| 1607 |
+
} = inputs;
|
| 1608 |
+
|
| 1609 |
const payload = {
|
| 1610 |
+
type: "remove-image-background",
|
| 1611 |
isFast: true,
|
| 1612 |
payload: {
|
| 1613 |
base64: false,
|
| 1614 |
+
model,
|
| 1615 |
+
image,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1616 |
},
|
| 1617 |
};
|
| 1618 |
+
try {
|
| 1619 |
+
const task = await artworks.createTask(payload);
|
| 1620 |
+
console.log(`Task created ${task}`);
|
| 1621 |
+
return RepeatNode.from({
|
| 1622 |
+
state: {
|
| 1623 |
+
payload,
|
| 1624 |
+
task,
|
| 1625 |
+
attempt: 0,
|
| 1626 |
+
startedAt: new Date()
|
| 1627 |
+
},
|
| 1628 |
+
progress: {
|
| 1629 |
+
total: MAX_ATTEMPTS,
|
| 1630 |
+
processed: 0
|
| 1631 |
+
},
|
| 1632 |
+
delay: 5000
|
| 1633 |
+
});
|
| 1634 |
+
} catch (e) {
|
| 1635 |
+
if (e instanceof ArtWorksError) {
|
| 1636 |
+
throw new FatalError(e.message);
|
| 1637 |
+
}
|
| 1638 |
+
throw e;
|
| 1639 |
+
}
|
| 1640 |
} else {
|
| 1641 |
const {
|
| 1642 |
payload,
|
|
|
|
| 1644 |
attempt,
|
| 1645 |
startedAt
|
| 1646 |
} = state;
|
| 1647 |
+
|
| 1648 |
+
if (attempt > MAX_ATTEMPTS) {
|
| 1649 |
+
try {
|
| 1650 |
+
await artworks.cancelTask(task);
|
| 1651 |
+
} catch (e) { }
|
| 1652 |
|
| 1653 |
const now = new Date();
|
| 1654 |
const time = (now - new Date(startedAt)) / 1000;
|
| 1655 |
+
throw new TimeoutError(`PaaS task for text to image ${task} timeout in ${time} sec`);
|
| 1656 |
}
|
| 1657 |
|
| 1658 |
+
console.log(`Check task ${attempt} ${task}`);
|
| 1659 |
+
|
| 1660 |
+
try {
|
| 1661 |
+
const results = await artworks.checkState(task);
|
| 1662 |
+
if (!results) {
|
| 1663 |
+
return RepeatNode.from({
|
| 1664 |
+
delay: CHECK_TASK_INTERVAL,
|
| 1665 |
+
state: {
|
| 1666 |
+
payload,
|
| 1667 |
+
task,
|
| 1668 |
+
attempt: attempt + 1,
|
| 1669 |
+
startedAt,
|
| 1670 |
+
},
|
| 1671 |
+
progress: {
|
| 1672 |
+
total: MAX_ATTEMPTS,
|
| 1673 |
+
processed: attempt
|
| 1674 |
+
},
|
| 1675 |
+
});
|
| 1676 |
+
}
|
| 1677 |
+
let { image: { url: image } } = results;
|
| 1678 |
+
return NextNode.from({
|
| 1679 |
+
outputs: {
|
| 1680 |
+
image
|
| 1681 |
+
}
|
| 1682 |
});
|
| 1683 |
+
} catch (e) {
|
| 1684 |
+
if (e instanceof ArtWorksError) {
|
| 1685 |
+
throw new FatalError(e.message);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1686 |
}
|
| 1687 |
+
throw e;
|
| 1688 |
+
}
|
| 1689 |
}
|
| 1690 |
+
}
|
|
|
|
| 1691 |
source: catalog
|
| 1692 |
+
title: en=Remove background;ru=Удалить фон
|
| 1693 |
version: 1
|