2023-09-10 20:00:49 +02:00
|
|
|
import { getPlatform } from "./get-device-specs";
|
2024-01-15 13:46:21 +01:00
|
|
|
import { ImageFormat } from "./types";
|
2023-04-29 02:18:19 +02:00
|
|
|
const slash: string = getPlatform() === "win" ? "\\" : "/";
|
|
|
|
|
2023-03-18 13:15:48 +01:00
|
|
|
export const getSingleImageArguments = (
|
|
|
|
inputDir: string,
|
|
|
|
fullfileName: string,
|
|
|
|
outFile: string,
|
|
|
|
modelsPath: string,
|
|
|
|
model: string,
|
|
|
|
scale: any,
|
|
|
|
gpuId: string,
|
2024-01-15 13:46:21 +01:00
|
|
|
saveImageAs: ImageFormat
|
2023-03-18 12:58:38 +01:00
|
|
|
) => {
|
2023-03-18 13:15:48 +01:00
|
|
|
return [
|
|
|
|
"-i",
|
2023-04-29 02:18:19 +02:00
|
|
|
inputDir + slash + fullfileName,
|
2023-03-18 13:15:48 +01:00
|
|
|
"-o",
|
|
|
|
outFile,
|
|
|
|
"-s",
|
2023-04-14 12:31:37 +02:00
|
|
|
scale,
|
2023-03-18 13:15:48 +01:00
|
|
|
"-m",
|
|
|
|
modelsPath,
|
|
|
|
"-n",
|
|
|
|
model,
|
2023-05-12 15:54:35 +02:00
|
|
|
gpuId ? "-g" : "",
|
|
|
|
gpuId ? gpuId : "",
|
2023-03-18 13:15:48 +01:00
|
|
|
"-f",
|
|
|
|
saveImageAs,
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
export const getSingleImageSharpenArguments = (
|
|
|
|
inputDir: string,
|
|
|
|
fullfileName: string,
|
|
|
|
outFile: string,
|
|
|
|
modelsPath: string,
|
|
|
|
model: string,
|
|
|
|
scale: any,
|
|
|
|
gpuId: string,
|
2024-01-15 13:46:21 +01:00
|
|
|
saveImageAs: ImageFormat
|
2023-03-18 13:15:48 +01:00
|
|
|
) => {
|
|
|
|
return [
|
|
|
|
"-i",
|
2023-04-29 02:18:19 +02:00
|
|
|
inputDir + slash + fullfileName,
|
2023-03-18 13:15:48 +01:00
|
|
|
"-o",
|
|
|
|
outFile,
|
|
|
|
"-s",
|
|
|
|
scale,
|
|
|
|
"-x",
|
|
|
|
"-m",
|
2023-04-29 02:18:19 +02:00
|
|
|
modelsPath + slash + model,
|
2023-05-12 15:54:35 +02:00
|
|
|
gpuId ? "-g" : "",
|
|
|
|
gpuId ? gpuId : "",
|
2023-03-18 13:15:48 +01:00
|
|
|
"-f",
|
|
|
|
saveImageAs,
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
export const getDoubleUpscaleArguments = (
|
|
|
|
inputDir: string,
|
|
|
|
fullfileName: string,
|
|
|
|
outFile: string,
|
|
|
|
modelsPath: string,
|
|
|
|
model: string,
|
|
|
|
gpuId: string,
|
2024-01-15 13:46:21 +01:00
|
|
|
saveImageAs: ImageFormat,
|
2023-04-14 12:31:37 +02:00
|
|
|
scale: string
|
2023-03-18 13:15:48 +01:00
|
|
|
) => {
|
|
|
|
return [
|
|
|
|
"-i",
|
2023-04-29 02:18:19 +02:00
|
|
|
inputDir + slash + fullfileName,
|
2023-03-18 13:15:48 +01:00
|
|
|
"-o",
|
|
|
|
outFile,
|
|
|
|
"-s",
|
2023-04-14 12:31:37 +02:00
|
|
|
scale,
|
2023-03-18 13:15:48 +01:00
|
|
|
"-m",
|
|
|
|
modelsPath,
|
|
|
|
"-n",
|
|
|
|
model,
|
2023-05-12 15:54:35 +02:00
|
|
|
gpuId ? "-g" : "",
|
|
|
|
gpuId ? gpuId : "",
|
2023-03-18 13:15:48 +01:00
|
|
|
"-f",
|
|
|
|
saveImageAs,
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
export const getDoubleUpscaleSecondPassArguments = (
|
|
|
|
isAlpha: boolean,
|
|
|
|
outFile: string,
|
|
|
|
modelsPath: string,
|
|
|
|
model: string,
|
|
|
|
gpuId: string,
|
2024-01-15 13:46:21 +01:00
|
|
|
saveImageAs: ImageFormat,
|
2023-04-14 12:31:37 +02:00
|
|
|
scale: string
|
2023-03-18 13:15:48 +01:00
|
|
|
) => {
|
|
|
|
return [
|
|
|
|
"-i",
|
|
|
|
isAlpha ? outFile + ".png" : outFile,
|
|
|
|
"-o",
|
|
|
|
isAlpha ? outFile + ".png" : outFile,
|
|
|
|
"-s",
|
2023-04-14 12:31:37 +02:00
|
|
|
scale,
|
2023-03-18 13:15:48 +01:00
|
|
|
"-m",
|
|
|
|
modelsPath,
|
|
|
|
"-n",
|
|
|
|
model,
|
2023-05-12 15:54:35 +02:00
|
|
|
gpuId ? "-g" : "",
|
|
|
|
gpuId ? gpuId : "",
|
2023-03-18 13:15:48 +01:00
|
|
|
"-f",
|
|
|
|
isAlpha ? "" : saveImageAs,
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
export const getBatchArguments = (
|
|
|
|
inputDir: string,
|
|
|
|
outputDir: string,
|
|
|
|
modelsPath: string,
|
|
|
|
model: string,
|
|
|
|
gpuId: string,
|
2024-01-15 13:46:21 +01:00
|
|
|
saveImageAs: ImageFormat,
|
2023-04-14 12:31:37 +02:00
|
|
|
scale: string
|
2023-03-18 13:15:48 +01:00
|
|
|
) => {
|
|
|
|
return [
|
|
|
|
"-i",
|
|
|
|
inputDir,
|
|
|
|
"-o",
|
|
|
|
outputDir,
|
|
|
|
"-s",
|
2023-04-14 12:31:37 +02:00
|
|
|
scale,
|
2023-03-18 13:15:48 +01:00
|
|
|
"-m",
|
|
|
|
modelsPath,
|
|
|
|
"-n",
|
|
|
|
model,
|
2023-05-12 15:54:35 +02:00
|
|
|
gpuId ? "-g" : "",
|
|
|
|
gpuId ? gpuId : "",
|
2023-03-18 13:15:48 +01:00
|
|
|
"-f",
|
|
|
|
saveImageAs,
|
2024-01-16 09:19:27 +01:00
|
|
|
];
|
2023-03-18 13:15:48 +01:00
|
|
|
};
|