2024-04-24 13:00:16 +02:00
|
|
|
import getModelScale from "../../common/check-model-scale";
|
2023-09-10 20:00:49 +02:00
|
|
|
import { getPlatform } from "./get-device-specs";
|
2024-04-24 12:34:32 +02:00
|
|
|
import { ImageFormat } from "../types/types";
|
2023-04-29 02:18:19 +02:00
|
|
|
const slash: string = getPlatform() === "win" ? "\\" : "/";
|
|
|
|
|
2024-04-09 20:11:24 +02:00
|
|
|
export const getSingleImageArguments = ({
|
|
|
|
inputDir,
|
2024-04-24 21:29:51 +02:00
|
|
|
fileNameWithExt,
|
2024-04-09 20:11:24 +02:00
|
|
|
outFile,
|
|
|
|
modelsPath,
|
|
|
|
model,
|
|
|
|
scale,
|
|
|
|
gpuId,
|
|
|
|
saveImageAs,
|
2024-04-20 17:44:42 +02:00
|
|
|
customWidth,
|
2024-04-24 21:40:48 +02:00
|
|
|
tileSize,
|
|
|
|
compression,
|
2024-04-09 20:11:24 +02:00
|
|
|
}: {
|
|
|
|
inputDir: string;
|
2024-04-24 21:29:51 +02:00
|
|
|
fileNameWithExt: string;
|
2024-04-09 20:11:24 +02:00
|
|
|
outFile: string;
|
|
|
|
modelsPath: string;
|
|
|
|
model: string;
|
2024-04-24 12:34:32 +02:00
|
|
|
scale: string;
|
2024-04-09 20:11:24 +02:00
|
|
|
gpuId: string;
|
|
|
|
saveImageAs: ImageFormat;
|
2024-04-20 17:44:42 +02:00
|
|
|
customWidth: string;
|
2024-04-24 21:40:48 +02:00
|
|
|
tileSize: number;
|
|
|
|
compression: string;
|
2024-04-09 20:11:24 +02:00
|
|
|
}) => {
|
2024-04-24 12:34:32 +02:00
|
|
|
const modelScale = getModelScale(model);
|
|
|
|
let includeScale = modelScale !== scale && !customWidth;
|
2023-03-18 13:15:48 +01:00
|
|
|
return [
|
2024-04-24 12:34:32 +02:00
|
|
|
// INPUT IMAGE
|
2023-03-18 13:15:48 +01:00
|
|
|
"-i",
|
2024-04-24 21:29:51 +02:00
|
|
|
inputDir + slash + fileNameWithExt,
|
2024-04-24 12:34:32 +02:00
|
|
|
// OUTPUT IMAGE
|
2023-03-18 13:15:48 +01:00
|
|
|
"-o",
|
|
|
|
outFile,
|
2024-04-24 12:34:32 +02:00
|
|
|
// OUTPUT SCALE
|
|
|
|
includeScale ? "-s" : "",
|
|
|
|
includeScale ? scale : "",
|
|
|
|
// MODELS PATH
|
2023-03-18 13:15:48 +01:00
|
|
|
"-m",
|
|
|
|
modelsPath,
|
2024-04-24 12:34:32 +02:00
|
|
|
// MODEL NAME
|
2023-03-18 13:15:48 +01:00
|
|
|
"-n",
|
|
|
|
model,
|
2024-04-24 12:34:32 +02:00
|
|
|
// GPU ID
|
|
|
|
gpuId ? "-g" : "",
|
|
|
|
gpuId ? gpuId : "",
|
|
|
|
// FORMAT
|
2023-03-18 13:15:48 +01:00
|
|
|
"-f",
|
|
|
|
saveImageAs,
|
2024-04-24 12:34:32 +02:00
|
|
|
// CUSTOM WIDTH
|
|
|
|
customWidth ? `-w` : "",
|
|
|
|
customWidth ? customWidth : "",
|
2024-04-24 21:40:48 +02:00
|
|
|
// COMPRESSION
|
|
|
|
"-c",
|
|
|
|
compression,
|
|
|
|
// TILE SIZE
|
|
|
|
tileSize ? `-t` : "",
|
|
|
|
tileSize ? tileSize.toString() : "",
|
2023-03-18 13:15:48 +01:00
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2024-04-09 20:11:24 +02:00
|
|
|
export const getDoubleUpscaleArguments = ({
|
|
|
|
inputDir,
|
|
|
|
fullfileName,
|
|
|
|
outFile,
|
|
|
|
modelsPath,
|
|
|
|
model,
|
|
|
|
gpuId,
|
|
|
|
saveImageAs,
|
2024-04-24 21:40:48 +02:00
|
|
|
tileSize,
|
2024-04-09 20:11:24 +02:00
|
|
|
}: {
|
|
|
|
inputDir: string;
|
|
|
|
fullfileName: string;
|
|
|
|
outFile: string;
|
|
|
|
modelsPath: string;
|
|
|
|
model: string;
|
|
|
|
gpuId: string;
|
|
|
|
saveImageAs: ImageFormat;
|
2024-04-24 21:40:48 +02:00
|
|
|
tileSize: number;
|
2024-04-09 20:11:24 +02:00
|
|
|
}) => {
|
2023-03-18 13:15:48 +01:00
|
|
|
return [
|
2024-04-24 12:34:32 +02:00
|
|
|
// INPUT IMAGE
|
2023-03-18 13:15:48 +01:00
|
|
|
"-i",
|
2023-04-29 02:18:19 +02:00
|
|
|
inputDir + slash + fullfileName,
|
2024-04-24 12:34:32 +02:00
|
|
|
// OUTPUT IMAGE
|
2023-03-18 13:15:48 +01:00
|
|
|
"-o",
|
|
|
|
outFile,
|
2024-04-24 12:34:32 +02:00
|
|
|
// MODELS PATH
|
2023-03-18 13:15:48 +01:00
|
|
|
"-m",
|
|
|
|
modelsPath,
|
2024-04-24 12:34:32 +02:00
|
|
|
// MODEL NAME
|
2023-03-18 13:15:48 +01:00
|
|
|
"-n",
|
|
|
|
model,
|
2024-04-24 12:34:32 +02:00
|
|
|
// GPU ID
|
|
|
|
gpuId ? `-g` : "",
|
|
|
|
gpuId ? gpuId : "",
|
|
|
|
// FORMAT
|
2023-03-18 13:15:48 +01:00
|
|
|
"-f",
|
|
|
|
saveImageAs,
|
2024-04-24 21:40:48 +02:00
|
|
|
// TILE SIZE
|
|
|
|
tileSize ? `-t` : "",
|
|
|
|
tileSize ? tileSize.toString() : "",
|
2023-03-18 13:15:48 +01:00
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2024-04-09 20:11:24 +02:00
|
|
|
export const getDoubleUpscaleSecondPassArguments = ({
|
|
|
|
outFile,
|
|
|
|
modelsPath,
|
|
|
|
model,
|
|
|
|
gpuId,
|
|
|
|
saveImageAs,
|
|
|
|
scale,
|
2024-04-20 17:44:42 +02:00
|
|
|
customWidth,
|
2024-04-24 21:40:48 +02:00
|
|
|
compression,
|
|
|
|
tileSize,
|
2024-04-09 20:11:24 +02:00
|
|
|
}: {
|
|
|
|
outFile: string;
|
|
|
|
modelsPath: string;
|
|
|
|
model: string;
|
|
|
|
gpuId: string;
|
|
|
|
saveImageAs: ImageFormat;
|
|
|
|
scale: string;
|
2024-04-20 17:44:42 +02:00
|
|
|
customWidth: string;
|
2024-04-24 21:29:51 +02:00
|
|
|
compression: string;
|
2024-04-24 21:40:48 +02:00
|
|
|
tileSize: number;
|
2024-04-09 20:11:24 +02:00
|
|
|
}) => {
|
2024-04-24 15:44:51 +02:00
|
|
|
const modelScale = (parseInt(getModelScale(model)) ** 2).toString();
|
2024-04-24 12:34:32 +02:00
|
|
|
let includeScale = modelScale !== scale && !customWidth;
|
2023-03-18 13:15:48 +01:00
|
|
|
return [
|
2024-04-24 12:34:32 +02:00
|
|
|
// INPUT IMAGE
|
2023-03-18 13:15:48 +01:00
|
|
|
"-i",
|
2024-04-21 19:14:39 +02:00
|
|
|
outFile,
|
2024-04-24 12:34:32 +02:00
|
|
|
// OUTPUT IMAGE
|
2023-03-18 13:15:48 +01:00
|
|
|
"-o",
|
2024-04-21 19:14:39 +02:00
|
|
|
outFile,
|
2024-04-24 12:34:32 +02:00
|
|
|
// OUTPUT SCALE
|
|
|
|
includeScale ? "-s" : "",
|
|
|
|
includeScale ? scale : "",
|
|
|
|
// MODELS PATH
|
2023-03-18 13:15:48 +01:00
|
|
|
"-m",
|
|
|
|
modelsPath,
|
2024-04-24 12:34:32 +02:00
|
|
|
// MODEL NAME
|
2023-03-18 13:15:48 +01:00
|
|
|
"-n",
|
|
|
|
model,
|
2024-04-24 12:34:32 +02:00
|
|
|
// GPU ID
|
|
|
|
gpuId ? `-g` : "",
|
|
|
|
gpuId ? gpuId : "",
|
|
|
|
// FORMAT
|
2024-04-21 19:14:39 +02:00
|
|
|
"-f",
|
|
|
|
saveImageAs,
|
2024-04-24 12:34:32 +02:00
|
|
|
// CUSTOM WIDTH
|
|
|
|
customWidth ? `-w` : "",
|
|
|
|
customWidth ? customWidth : "",
|
2024-04-24 21:40:48 +02:00
|
|
|
// COMPRESSION
|
|
|
|
"-c",
|
|
|
|
compression,
|
|
|
|
// TILE SIZE
|
|
|
|
tileSize ? `-t` : "",
|
|
|
|
tileSize ? tileSize.toString() : "",
|
2023-03-18 13:15:48 +01:00
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2024-04-09 20:11:24 +02:00
|
|
|
export const getBatchArguments = ({
|
|
|
|
inputDir,
|
|
|
|
outputDir,
|
|
|
|
modelsPath,
|
|
|
|
model,
|
|
|
|
gpuId,
|
|
|
|
saveImageAs,
|
|
|
|
scale,
|
2024-04-20 17:44:42 +02:00
|
|
|
customWidth,
|
2024-04-24 21:40:48 +02:00
|
|
|
compression,
|
|
|
|
tileSize,
|
2024-04-09 20:11:24 +02:00
|
|
|
}: {
|
|
|
|
inputDir: string;
|
|
|
|
outputDir: string;
|
|
|
|
modelsPath: string;
|
|
|
|
model: string;
|
|
|
|
gpuId: string;
|
|
|
|
saveImageAs: ImageFormat;
|
|
|
|
scale: string;
|
2024-04-20 17:44:42 +02:00
|
|
|
customWidth: string;
|
2024-04-24 21:40:48 +02:00
|
|
|
compression: string;
|
|
|
|
tileSize: number;
|
2024-04-09 20:11:24 +02:00
|
|
|
}) => {
|
2024-04-24 12:34:32 +02:00
|
|
|
const modelScale = getModelScale(model);
|
|
|
|
let includeScale = modelScale !== scale && !customWidth;
|
|
|
|
|
2023-03-18 13:15:48 +01:00
|
|
|
return [
|
2024-04-24 12:34:32 +02:00
|
|
|
// INPUT IMAGE
|
2023-03-18 13:15:48 +01:00
|
|
|
"-i",
|
|
|
|
inputDir,
|
2024-04-24 12:34:32 +02:00
|
|
|
// OUTPUT IMAGE
|
2023-03-18 13:15:48 +01:00
|
|
|
"-o",
|
|
|
|
outputDir,
|
2024-04-24 12:34:32 +02:00
|
|
|
// OUTPUT SCALE
|
|
|
|
includeScale ? "-s" : "",
|
|
|
|
includeScale ? scale : "",
|
|
|
|
// MODELS PATH
|
2023-03-18 13:15:48 +01:00
|
|
|
"-m",
|
|
|
|
modelsPath,
|
2024-04-24 12:34:32 +02:00
|
|
|
// MODEL NAME
|
2023-03-18 13:15:48 +01:00
|
|
|
"-n",
|
|
|
|
model,
|
2024-04-24 12:34:32 +02:00
|
|
|
// GPU ID
|
|
|
|
gpuId ? `-g` : "",
|
|
|
|
gpuId ? gpuId : "",
|
|
|
|
// FORMAT
|
2023-03-18 13:15:48 +01:00
|
|
|
"-f",
|
|
|
|
saveImageAs,
|
2024-04-24 12:34:32 +02:00
|
|
|
// CUSTOM WIDTH
|
|
|
|
customWidth ? `-w` : "",
|
|
|
|
customWidth ? customWidth : "",
|
2024-04-24 21:40:48 +02:00
|
|
|
// COMPRESSION
|
|
|
|
"-c",
|
|
|
|
compression,
|
|
|
|
// TILE SIZE
|
|
|
|
tileSize ? `-t` : "",
|
|
|
|
tileSize ? tileSize.toString() : "",
|
2024-01-16 09:19:27 +01:00
|
|
|
];
|
2023-03-18 13:15:48 +01:00
|
|
|
};
|