upres-cli 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -18
- package/dist/cli.cjs +146 -113
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +146 -113
- package/dist/cli.js.map +1 -1
- package/dist/client.cjs +27 -13
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +5 -1
- package/dist/client.d.ts +5 -1
- package/dist/client.js +25 -12
- package/dist/client.js.map +1 -1
- package/dist/mcp.cjs +80 -84
- package/dist/mcp.cjs.map +1 -1
- package/dist/mcp.js +80 -84
- package/dist/mcp.js.map +1 -1
- package/dist/models.cjs +49 -74
- package/dist/models.cjs.map +1 -1
- package/dist/models.d.cts +3 -1
- package/dist/models.d.ts +3 -1
- package/dist/models.js +47 -74
- package/dist/models.js.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +48 -11
package/dist/cli.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __esm = (fn, res) => function __init() {
|
|
5
|
-
|
|
4
|
+
var __esm = (fn, res, err) => function __init() {
|
|
5
|
+
if (err) throw err[0];
|
|
6
|
+
try {
|
|
7
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
8
|
+
} catch (e) {
|
|
9
|
+
throw err = [e], e;
|
|
10
|
+
}
|
|
6
11
|
};
|
|
7
12
|
var __export = (target, all) => {
|
|
8
13
|
for (var name in all)
|
|
@@ -10,88 +15,59 @@ var __export = (target, all) => {
|
|
|
10
15
|
};
|
|
11
16
|
|
|
12
17
|
// src/models.ts
|
|
13
|
-
|
|
18
|
+
function scaleParam(maxScale) {
|
|
19
|
+
if (maxScale <= 1) return [];
|
|
20
|
+
const options = [];
|
|
21
|
+
for (let step = 2; step <= maxScale; step *= 2) options.push(step);
|
|
22
|
+
return [
|
|
23
|
+
{
|
|
24
|
+
name: "scale",
|
|
25
|
+
type: "integer",
|
|
26
|
+
required: false,
|
|
27
|
+
default: 4,
|
|
28
|
+
options,
|
|
29
|
+
description: "Scale multiplier. Ignored when the alias does not enlarge."
|
|
30
|
+
}
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
function model(id, name, description, category, inputTypes, maxScale) {
|
|
34
|
+
const fileParam = category.startsWith("video") ? { name: "video", type: "string", required: true, description: "Video URL or file" } : category.startsWith("audio") ? { name: "audio", type: "string", required: true, description: "Audio URL or file" } : { name: "image", type: "string", required: true, description: "Image URL or file" };
|
|
35
|
+
return {
|
|
36
|
+
id,
|
|
37
|
+
name,
|
|
38
|
+
description,
|
|
39
|
+
category,
|
|
40
|
+
price: "One credit per stage that runs",
|
|
41
|
+
inputTypes,
|
|
42
|
+
params: [fileParam, ...scaleParam(maxScale)]
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
var MODELS, IMAGE_MODELS, VIDEO_MODELS, AUDIO_MODELS, DEFAULT_IMAGE_MODEL, DEFAULT_VIDEO_MODEL, DEFAULT_AUDIO_MODEL;
|
|
14
46
|
var init_models = __esm({
|
|
15
47
|
"src/models.ts"() {
|
|
16
48
|
"use strict";
|
|
17
49
|
MODELS = [
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
name: "Prism",
|
|
33
|
-
description: "Text, logos, screenshots and product shots. Keeps edges true, does not invent detail.",
|
|
34
|
-
category: "image-upscale",
|
|
35
|
-
price: "Included in plan quota",
|
|
36
|
-
inputTypes: ["image/*"],
|
|
37
|
-
params: [
|
|
38
|
-
{ name: "image", type: "string", required: true, description: "Image URL or file" },
|
|
39
|
-
{ name: "scale", type: "integer", required: false, default: 4, options: [2, 4], description: "Scale multiplier" }
|
|
40
|
-
]
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
id: "lumen",
|
|
44
|
-
name: "Lumen",
|
|
45
|
-
description: "Maximum detail recovery for print, up to 8x. Slower and dearer than Flare.",
|
|
46
|
-
category: "image-upscale",
|
|
47
|
-
price: "Included in plan quota",
|
|
48
|
-
inputTypes: ["image/*"],
|
|
49
|
-
params: [
|
|
50
|
-
{ name: "image", type: "string", required: true, description: "Image URL or file" },
|
|
51
|
-
{ name: "scale", type: "integer", required: false, default: 4, options: [2, 4, 8], description: "Scale multiplier" }
|
|
52
|
-
]
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
id: "mirage",
|
|
56
|
-
name: "Mirage",
|
|
57
|
-
description: "Invents plausible new detail rather than recovering what was there. Most dramatic, least faithful. Good for art, wrong for documents.",
|
|
58
|
-
category: "image-enhance",
|
|
59
|
-
price: "Included in plan quota",
|
|
60
|
-
inputTypes: ["image/*"],
|
|
61
|
-
params: [
|
|
62
|
-
{ name: "image", type: "string", required: true, description: "Image URL or file" },
|
|
63
|
-
{ name: "scale", type: "integer", required: false, default: 4, options: [2, 4, 8], description: "Scale multiplier" }
|
|
64
|
-
]
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
id: "motion",
|
|
68
|
-
name: "Motion",
|
|
69
|
-
description: "Fast 4K finish for AI-generated video (Sora, Kling, Runway). Frame-consistent, does not invent faces.",
|
|
70
|
-
category: "video-upscale",
|
|
71
|
-
price: "Counts against monthly video minutes",
|
|
72
|
-
inputTypes: ["video/*"],
|
|
73
|
-
params: [
|
|
74
|
-
{ name: "video", type: "string", required: true, description: "Video URL or file" },
|
|
75
|
-
{ name: "scale", type: "integer", required: false, default: 4, options: [2, 4], description: "Scale multiplier" }
|
|
76
|
-
]
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
id: "motion-x",
|
|
80
|
-
name: "Motion X",
|
|
81
|
-
description: "Cinema-grade video upscale for film and commercials. Noticeably slower and dearer per second than Motion.",
|
|
82
|
-
category: "video-upscale",
|
|
83
|
-
price: "Counts against monthly video minutes",
|
|
84
|
-
inputTypes: ["video/*"],
|
|
85
|
-
params: [
|
|
86
|
-
{ name: "video", type: "string", required: true, description: "Video URL or file" },
|
|
87
|
-
{ name: "scale", type: "integer", required: false, default: 4, options: [2, 4], description: "Scale multiplier" }
|
|
88
|
-
]
|
|
89
|
-
}
|
|
50
|
+
model("flare", "Flare", "Everyday photos, 2x-4x. Fastest and cheapest. Does not invent detail.", "image-upscale", ["image/*"], 4),
|
|
51
|
+
model("prism", "Prism", "Text, logos, screenshots and product shots. Keeps edges true, does not invent detail.", "image-upscale", ["image/*"], 4),
|
|
52
|
+
model("lumen", "Lumen", "Maximum detail recovery for print, up to 8x. Slower and dearer than Flare.", "image-upscale", ["image/*"], 8),
|
|
53
|
+
model("mirage", "Mirage", "Invents plausible new detail rather than recovering what was there. Good for art, wrong for documents.", "image-upscale", ["image/*"], 8),
|
|
54
|
+
model("hush", "Hush", "Faithful denoise. Same size as the source, nothing invented.", "image-clean", ["image/*"], 1),
|
|
55
|
+
model("keen", "Keen", "Deblur and sharpen. Same size as the source, does not invent texture.", "image-restore", ["image/*"], 1),
|
|
56
|
+
model("visage", "Visage", "Restores faces and leaves the rest of the frame alone. Does not enlarge.", "image-restore", ["image/*"], 1),
|
|
57
|
+
model("atelier", "Atelier", "Hush, then Visage if the photo looks like a portrait, then Lumen. A skipped face stage is free.", "image-studio", ["image/*"], 8),
|
|
58
|
+
model("motion", "Motion", "Fast 4K finish for AI-generated video. Frame-consistent, does not invent faces.", "video-upscale", ["video/*"], 4),
|
|
59
|
+
model("motion-x", "Motion X", "Cinema-grade video upscale. Noticeably slower and dearer per second than Motion.", "video-upscale", ["video/*"], 4),
|
|
60
|
+
model("still", "Still", "Temporal video denoise. Resolution stays put.", "video-clean", ["video/*"], 1),
|
|
61
|
+
model("cadence", "Cadence", "Frame interpolation. Does not enlarge the picture.", "video-restore", ["video/*"], 1),
|
|
62
|
+
model("atelier-x", "Atelier X", "Still, then Motion X. Two credits.", "video-studio", ["video/*"], 4),
|
|
63
|
+
model("voice", "Voice", "Speech denoise and bandwidth extension to 48 kHz. Not for music.", "audio-clean", ["audio/*"], 1)
|
|
90
64
|
];
|
|
91
|
-
IMAGE_MODELS = MODELS.filter((m) => m.category
|
|
92
|
-
VIDEO_MODELS = MODELS.filter((m) => m.category
|
|
65
|
+
IMAGE_MODELS = MODELS.filter((m) => m.category.startsWith("image"));
|
|
66
|
+
VIDEO_MODELS = MODELS.filter((m) => m.category.startsWith("video"));
|
|
67
|
+
AUDIO_MODELS = MODELS.filter((m) => m.category.startsWith("audio"));
|
|
93
68
|
DEFAULT_IMAGE_MODEL = "flare";
|
|
94
69
|
DEFAULT_VIDEO_MODEL = "motion";
|
|
70
|
+
DEFAULT_AUDIO_MODEL = "voice";
|
|
95
71
|
}
|
|
96
72
|
});
|
|
97
73
|
|
|
@@ -175,6 +151,15 @@ async function callTool(name, args) {
|
|
|
175
151
|
});
|
|
176
152
|
return text(job);
|
|
177
153
|
}
|
|
154
|
+
case "upres_enhance_audio": {
|
|
155
|
+
const audio_url = String(args.audio_url ?? "");
|
|
156
|
+
if (!audio_url) throw new Error("audio_url is required");
|
|
157
|
+
const job = await api("POST", "/jobs", {
|
|
158
|
+
image_url: audio_url,
|
|
159
|
+
model: args.model ?? "voice"
|
|
160
|
+
});
|
|
161
|
+
return text(job);
|
|
162
|
+
}
|
|
178
163
|
case "upres_get_job": {
|
|
179
164
|
const job_id = String(args.job_id ?? "");
|
|
180
165
|
if (!job_id) throw new Error("job_id is required");
|
|
@@ -245,12 +230,12 @@ var init_mcp = __esm({
|
|
|
245
230
|
"src/mcp.ts"() {
|
|
246
231
|
"use strict";
|
|
247
232
|
init_models();
|
|
248
|
-
VERSION = "0.
|
|
233
|
+
VERSION = "0.3.0";
|
|
249
234
|
DEFAULT_BASE_URL2 = "https://api.upres.ai/v1";
|
|
250
235
|
TOOLS = [
|
|
251
236
|
{
|
|
252
237
|
name: "upres_list_models",
|
|
253
|
-
description: "List
|
|
238
|
+
description: "List the 14 public UpRes aliases for image, video, and speech.",
|
|
254
239
|
inputSchema: { type: "object", properties: {}, additionalProperties: false }
|
|
255
240
|
},
|
|
256
241
|
{
|
|
@@ -260,17 +245,17 @@ var init_mcp = __esm({
|
|
|
260
245
|
},
|
|
261
246
|
{
|
|
262
247
|
name: "upres_upscale_image",
|
|
263
|
-
description: "Submit an image
|
|
248
|
+
description: "Submit an image job from a public URL. Upscale: flare, prism, lumen, mirage. Restore: hush, keen, visage, atelier. Scale is ignored when the alias does not enlarge.",
|
|
264
249
|
inputSchema: {
|
|
265
250
|
type: "object",
|
|
266
251
|
properties: {
|
|
267
252
|
image_url: { type: "string", description: "Public HTTPS URL of the image" },
|
|
268
253
|
model: {
|
|
269
254
|
type: "string",
|
|
270
|
-
enum:
|
|
271
|
-
description: "Image
|
|
255
|
+
enum: IMAGE_MODELS.map((m) => m.id),
|
|
256
|
+
description: "Image alias. Default flare."
|
|
272
257
|
},
|
|
273
|
-
scale: { type: "integer", enum: [2, 4, 8], description: "Scale multiplier. Default 4." }
|
|
258
|
+
scale: { type: "integer", enum: [2, 4, 8], description: "Scale multiplier. Default 4. Ignored for hush, keen, and visage." }
|
|
274
259
|
},
|
|
275
260
|
required: ["image_url"],
|
|
276
261
|
additionalProperties: false
|
|
@@ -278,22 +263,39 @@ var init_mcp = __esm({
|
|
|
278
263
|
},
|
|
279
264
|
{
|
|
280
265
|
name: "upres_upscale_video",
|
|
281
|
-
description: "Submit a video
|
|
266
|
+
description: "Submit a video job from a public URL. motion and motion-x upscale. still denoises, cadence interpolates frames, atelier-x runs still then motion-x.",
|
|
282
267
|
inputSchema: {
|
|
283
268
|
type: "object",
|
|
284
269
|
properties: {
|
|
285
270
|
video_url: { type: "string", description: "Public HTTPS URL of the video" },
|
|
286
271
|
model: {
|
|
287
272
|
type: "string",
|
|
288
|
-
enum:
|
|
289
|
-
description: "Video
|
|
273
|
+
enum: VIDEO_MODELS.map((m) => m.id),
|
|
274
|
+
description: "Video alias. Default motion."
|
|
290
275
|
},
|
|
291
|
-
scale: { type: "integer", enum: [2, 4], description: "Scale multiplier. Default 4." }
|
|
276
|
+
scale: { type: "integer", enum: [2, 4], description: "Scale multiplier. Default 4. Ignored for still and cadence." }
|
|
292
277
|
},
|
|
293
278
|
required: ["video_url"],
|
|
294
279
|
additionalProperties: false
|
|
295
280
|
}
|
|
296
281
|
},
|
|
282
|
+
{
|
|
283
|
+
name: "upres_enhance_audio",
|
|
284
|
+
description: "Submit a speech job from a public URL. voice denoises speech and extends it to 48 kHz. Music is not supported.",
|
|
285
|
+
inputSchema: {
|
|
286
|
+
type: "object",
|
|
287
|
+
properties: {
|
|
288
|
+
audio_url: { type: "string", description: "Public HTTPS URL of wav, mp3, m4a, or flac speech" },
|
|
289
|
+
model: {
|
|
290
|
+
type: "string",
|
|
291
|
+
enum: AUDIO_MODELS.map((m) => m.id),
|
|
292
|
+
description: "Audio alias. Default voice."
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
required: ["audio_url"],
|
|
296
|
+
additionalProperties: false
|
|
297
|
+
}
|
|
298
|
+
},
|
|
297
299
|
{
|
|
298
300
|
name: "upres_get_job",
|
|
299
301
|
description: "Get status and result_url of an UpRes job by id.",
|
|
@@ -334,13 +336,20 @@ function loadConfigFile() {
|
|
|
334
336
|
function resolveApiKey(override) {
|
|
335
337
|
const key = override ?? process.env.UPRES_API_KEY ?? loadConfigFile().apiKey;
|
|
336
338
|
if (!key) {
|
|
337
|
-
|
|
338
|
-
"
|
|
339
|
+
throw new Error(
|
|
340
|
+
"No API key found.\n Set UPRES_API_KEY env var, pass --api-key, or save to ~/.config/upres/config.json\n Get a key at https://upres.ai/account/api-keys"
|
|
339
341
|
);
|
|
340
|
-
process.exit(1);
|
|
341
342
|
}
|
|
342
343
|
return key;
|
|
343
344
|
}
|
|
345
|
+
var UpresError = class extends Error {
|
|
346
|
+
constructor(message, status) {
|
|
347
|
+
super(message);
|
|
348
|
+
this.status = status;
|
|
349
|
+
this.name = "UpresError";
|
|
350
|
+
}
|
|
351
|
+
status;
|
|
352
|
+
};
|
|
344
353
|
var UpresClient = class {
|
|
345
354
|
apiKey;
|
|
346
355
|
baseUrl;
|
|
@@ -361,19 +370,24 @@ var UpresClient = class {
|
|
|
361
370
|
if (!res.ok) {
|
|
362
371
|
const err = await res.json().catch(() => ({ error: `HTTP ${res.status}` }));
|
|
363
372
|
if (res.status === 401) {
|
|
364
|
-
|
|
365
|
-
process.exit(1);
|
|
373
|
+
throw new UpresError(`Invalid API key. Get a new key at https://upres.ai/account/api-keys`, res.status);
|
|
366
374
|
}
|
|
367
375
|
if (res.status === 402) {
|
|
368
|
-
|
|
369
|
-
`
|
|
370
|
-
Upgrade
|
|
376
|
+
throw new UpresError(
|
|
377
|
+
`Monthly quota exceeded (used ${err.used ?? "?"}/${err.quota ?? "?"}).
|
|
378
|
+
Upgrade your plan at https://upres.ai/pricing`,
|
|
379
|
+
res.status
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
if (res.status === 403) {
|
|
383
|
+
throw new UpresError(
|
|
384
|
+
`${err.error ?? "API access requires the Business plan."}
|
|
385
|
+
Your key is kept and works again on Business: https://upres.ai/pricing`,
|
|
386
|
+
res.status
|
|
371
387
|
);
|
|
372
|
-
process.exit(1);
|
|
373
388
|
}
|
|
374
389
|
if (res.status === 429) {
|
|
375
|
-
|
|
376
|
-
process.exit(1);
|
|
390
|
+
throw new UpresError(`Rate limit exceeded (60 req/min). Wait a moment and retry.`, res.status);
|
|
377
391
|
}
|
|
378
392
|
throw new Error(err.error ?? `HTTP ${res.status}`);
|
|
379
393
|
}
|
|
@@ -476,7 +490,7 @@ var UpresClient = class {
|
|
|
476
490
|
|
|
477
491
|
// src/cli.ts
|
|
478
492
|
init_models();
|
|
479
|
-
var VERSION2 = "0.
|
|
493
|
+
var VERSION2 = "0.3.0";
|
|
480
494
|
function parseArgs(argv) {
|
|
481
495
|
const args = [];
|
|
482
496
|
const flags = {};
|
|
@@ -517,7 +531,7 @@ COMMANDS
|
|
|
517
531
|
version Print version
|
|
518
532
|
|
|
519
533
|
OPTIONS
|
|
520
|
-
--model <id>
|
|
534
|
+
--model <id> Public alias (default: flare, motion for video, voice for speech)
|
|
521
535
|
--scale <n> Scale factor 2-8 (default: 4)
|
|
522
536
|
--output <path> Output file or directory
|
|
523
537
|
--api-key <key> API key (or set UPRES_API_KEY env var)
|
|
@@ -538,14 +552,16 @@ EXAMPLES
|
|
|
538
552
|
upres account
|
|
539
553
|
|
|
540
554
|
API KEY
|
|
541
|
-
1. Get a
|
|
555
|
+
1. Get a key on the Business plan at https://upres.ai/account/api-keys
|
|
542
556
|
2. Export: UPRES_API_KEY=upres_yourkey
|
|
543
557
|
3. Or save: echo '{"apiKey":"upres_yourkey"}' > ~/.config/upres/config.json
|
|
544
558
|
|
|
545
559
|
PRICING
|
|
546
|
-
Free:
|
|
547
|
-
Creator:
|
|
548
|
-
|
|
560
|
+
Free: 5 upscales/month
|
|
561
|
+
Creator: $9/month \u2014 50 upscales + 20 videos up to 8K
|
|
562
|
+
Pro: $19/month \u2014 100 upscales + 30 videos up to 8K
|
|
563
|
+
Studio: $39/month \u2014 250 upscales + 90 videos up to 8K
|
|
564
|
+
Business: $49/month \u2014 500 upscales + 150 videos up to 8K + API
|
|
549
565
|
|
|
550
566
|
https://upres.ai/pricing
|
|
551
567
|
`);
|
|
@@ -559,6 +575,8 @@ function resolveModel(modelArg, filePath) {
|
|
|
559
575
|
}
|
|
560
576
|
const ext = path2.extname(filePath).toLowerCase();
|
|
561
577
|
const videoExts = [".mp4", ".mov", ".avi", ".mkv", ".webm", ".gif"];
|
|
578
|
+
const audioExts = [".wav", ".mp3", ".m4a", ".flac"];
|
|
579
|
+
if (audioExts.includes(ext)) return DEFAULT_AUDIO_MODEL;
|
|
562
580
|
return videoExts.includes(ext) ? DEFAULT_VIDEO_MODEL : DEFAULT_IMAGE_MODEL;
|
|
563
581
|
}
|
|
564
582
|
function resolveOutputPath(input, outputDir) {
|
|
@@ -579,7 +597,7 @@ async function cmdUpscale(args, flags) {
|
|
|
579
597
|
process.exit(1);
|
|
580
598
|
}
|
|
581
599
|
const client = new UpresClient({ apiKey: flags["api-key"] });
|
|
582
|
-
const
|
|
600
|
+
const model2 = resolveModel(flags.model, input);
|
|
583
601
|
const scale = flags.scale ? Number(flags.scale) : 4;
|
|
584
602
|
const resolution = flags.resolution ?? "4k";
|
|
585
603
|
const outputPath = flags.output;
|
|
@@ -590,9 +608,9 @@ async function cmdUpscale(args, flags) {
|
|
|
590
608
|
console.error(`Error: File not found: ${input}`);
|
|
591
609
|
process.exit(1);
|
|
592
610
|
}
|
|
593
|
-
process.stdout.write(`Submitting job... model=${
|
|
611
|
+
process.stdout.write(`Submitting job... model=${model2}
|
|
594
612
|
`);
|
|
595
|
-
let job = isFile ? await client.createJobFromFile(input, { model, scale }) : await client.createJobFromUrl(input, { model, scale });
|
|
613
|
+
let job = isFile ? await client.createJobFromFile(input, { model: model2, scale }) : await client.createJobFromUrl(input, { model: model2, scale });
|
|
596
614
|
console.log(`Job created: ${job.id} (status: ${job.status})`);
|
|
597
615
|
if (noWait) {
|
|
598
616
|
console.log(`Run "upres jobs" to check status.`);
|
|
@@ -631,17 +649,18 @@ async function cmdBatch(args, flags) {
|
|
|
631
649
|
process.exit(1);
|
|
632
650
|
}
|
|
633
651
|
const outputDir = flags.output ?? path2.join(dir, "upscaled");
|
|
634
|
-
const
|
|
652
|
+
const model2 = resolveModel(flags.model, files[0]);
|
|
635
653
|
const scale = flags.scale ? Number(flags.scale) : 4;
|
|
636
654
|
const concurrency = flags.concurrency ? Number(flags.concurrency) : 3;
|
|
637
|
-
console.log(`Batch upscaling ${files.length} images with ${
|
|
655
|
+
console.log(`Batch upscaling ${files.length} images with ${model2} (concurrency: ${concurrency})`);
|
|
638
656
|
const client = new UpresClient({ apiKey: flags["api-key"] });
|
|
639
657
|
let done = 0;
|
|
640
658
|
let failed = 0;
|
|
659
|
+
let accountError = false;
|
|
641
660
|
async function processFile(filePath) {
|
|
642
661
|
const filename = path2.basename(filePath);
|
|
643
662
|
try {
|
|
644
|
-
const job = await client.createJobFromFile(filePath, { model, scale });
|
|
663
|
+
const job = await client.createJobFromFile(filePath, { model: model2, scale });
|
|
645
664
|
const completed = await client.waitForJob(job.id);
|
|
646
665
|
if (completed.status === "failed") {
|
|
647
666
|
console.error(` FAILED ${filename}: ${completed.error}`);
|
|
@@ -655,21 +674,34 @@ async function cmdBatch(args, flags) {
|
|
|
655
674
|
} catch (e) {
|
|
656
675
|
console.error(` ERROR ${filename}: ${e.message}`);
|
|
657
676
|
failed++;
|
|
677
|
+
if (e instanceof UpresError) accountError = true;
|
|
658
678
|
}
|
|
659
679
|
}
|
|
660
680
|
for (let i = 0; i < files.length; i += concurrency) {
|
|
661
681
|
const chunk = files.slice(i, i + concurrency);
|
|
662
682
|
await Promise.all(chunk.map(processFile));
|
|
683
|
+
if (accountError) break;
|
|
663
684
|
}
|
|
664
685
|
console.log(`
|
|
665
686
|
Done: ${done} succeeded, ${failed} failed. Output: ${outputDir}`);
|
|
687
|
+
if (failed > 0) process.exitCode = 1;
|
|
666
688
|
}
|
|
689
|
+
var CATEGORY_LABEL = {
|
|
690
|
+
"image-upscale": "Image Upscale",
|
|
691
|
+
"image-clean": "Image Clean",
|
|
692
|
+
"image-restore": "Image Restore",
|
|
693
|
+
"image-studio": "Image Studio",
|
|
694
|
+
"video-upscale": "Video Upscale",
|
|
695
|
+
"video-clean": "Video Clean",
|
|
696
|
+
"video-restore": "Video Restore",
|
|
697
|
+
"video-studio": "Video Studio",
|
|
698
|
+
"audio-clean": "Speech"
|
|
699
|
+
};
|
|
667
700
|
function cmdModels() {
|
|
668
|
-
const categories = [
|
|
701
|
+
const categories = [...new Set(MODELS.map((m) => m.category))];
|
|
669
702
|
for (const cat of categories) {
|
|
670
|
-
const label = { "image-upscale": "Image Upscale", "image-enhance": "Image Enhance", "video-upscale": "Video Upscale" }[cat];
|
|
671
703
|
console.log(`
|
|
672
|
-
${
|
|
704
|
+
${CATEGORY_LABEL[cat] ?? cat}`);
|
|
673
705
|
console.log("\u2500".repeat(60));
|
|
674
706
|
for (const m of MODELS.filter((x) => x.category === cat)) {
|
|
675
707
|
console.log(` ${m.id.padEnd(44)} ${m.price}`);
|
|
@@ -716,6 +748,7 @@ Account info (based on recent jobs)`);
|
|
|
716
748
|
console.log(` API keys: https://upres.ai/account/api-keys`);
|
|
717
749
|
} catch (e) {
|
|
718
750
|
console.error(e.message);
|
|
751
|
+
process.exitCode = 1;
|
|
719
752
|
}
|
|
720
753
|
}
|
|
721
754
|
async function main() {
|