mirror of
https://github.com/upscayl/upscayl.git
synced 2025-02-07 15:01:24 +01:00
added sharpen mode for normal and batch mode
This commit is contained in:
parent
39b42aca9c
commit
b8ee88ebb3
@ -15,7 +15,7 @@ const binariesPath = isDev
|
|||||||
|
|
||||||
const execPath = (execName) =>
|
const execPath = (execName) =>
|
||||||
resolve(join(binariesPath, `./upscayl-${execName}`));
|
resolve(join(binariesPath, `./upscayl-${execName}`));
|
||||||
|
|
||||||
const modelsPath = isDev
|
const modelsPath = isDev
|
||||||
? resolve(join(appRootDir.get(), "resources", "models"))
|
? resolve(join(appRootDir.get(), "resources", "models"))
|
||||||
: resolve(join(dirname(appRootDir.get()), "models"));
|
: resolve(join(dirname(appRootDir.get()), "models"));
|
||||||
|
133
main/index.js
133
main/index.js
@ -231,32 +231,66 @@ ipcMain.on(commands.UPSCAYL, async (event, payload) => {
|
|||||||
console.log(fullfileName);
|
console.log(fullfileName);
|
||||||
const fileName = parse(fullfileName).name;
|
const fileName = parse(fullfileName).name;
|
||||||
const fileExt = parse(fullfileName).ext;
|
const fileExt = parse(fullfileName).ext;
|
||||||
const outFile =
|
const outFile = model.includes("realesrgan")
|
||||||
outputDir + "/" + fileName + "_upscayl_" + scale + "x_" + model + fileExt;
|
? outputDir + "/" + fileName + "_upscayl_" + scale + "x_" + model + fileExt
|
||||||
|
: outputDir +
|
||||||
|
"/" +
|
||||||
|
fileName +
|
||||||
|
"_upscayl_sharpened_" +
|
||||||
|
scale +
|
||||||
|
"x_" +
|
||||||
|
model +
|
||||||
|
fileExt;
|
||||||
// UPSCALE
|
// UPSCALE
|
||||||
if (fs.existsSync(outFile)) {
|
if (fs.existsSync(outFile)) {
|
||||||
// If already upscayled, just output that file
|
// If already upscayled, just output that file
|
||||||
mainWindow.webContents.send(commands.UPSCAYL_DONE, outFile);
|
mainWindow.webContents.send(commands.UPSCAYL_DONE, outFile);
|
||||||
} else {
|
} else {
|
||||||
let upscayl = spawn(
|
let upscayl = null;
|
||||||
execPath("realesrgan"),
|
switch (model) {
|
||||||
[
|
case "realesrgan-x4plus":
|
||||||
"-i",
|
case "realesrgan-x4plus-anime":
|
||||||
inputDir + "/" + fullfileName,
|
upscayl = spawn(
|
||||||
"-o",
|
execPath("realesrgan"),
|
||||||
outFile,
|
[
|
||||||
"-s",
|
"-i",
|
||||||
scale === 2 ? 4 : scale,
|
inputDir + "/" + fullfileName,
|
||||||
"-m",
|
"-o",
|
||||||
modelsPath,
|
outFile,
|
||||||
"-n",
|
"-s",
|
||||||
model,
|
scale === 2 ? 4 : scale,
|
||||||
],
|
"-m",
|
||||||
{
|
modelsPath,
|
||||||
cwd: null,
|
"-n",
|
||||||
detached: false,
|
model,
|
||||||
}
|
],
|
||||||
);
|
{
|
||||||
|
cwd: null,
|
||||||
|
detached: false,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case "models-DF2K":
|
||||||
|
upscayl = spawn(
|
||||||
|
execPath("realsr"),
|
||||||
|
[
|
||||||
|
"-i",
|
||||||
|
inputDir + "/" + fullfileName,
|
||||||
|
"-o",
|
||||||
|
outFile,
|
||||||
|
"-s",
|
||||||
|
scale,
|
||||||
|
"-x",
|
||||||
|
"-m",
|
||||||
|
modelsPath + "/" + model,
|
||||||
|
],
|
||||||
|
{
|
||||||
|
cwd: null,
|
||||||
|
detached: false,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
let failed = false;
|
let failed = false;
|
||||||
upscayl.stderr.on("data", (data) => {
|
upscayl.stderr.on("data", (data) => {
|
||||||
@ -291,20 +325,59 @@ ipcMain.on(commands.UPSCAYL, async (event, payload) => {
|
|||||||
ipcMain.on(commands.FOLDER_UPSCAYL, async (event, payload) => {
|
ipcMain.on(commands.FOLDER_UPSCAYL, async (event, payload) => {
|
||||||
const model = payload.model;
|
const model = payload.model;
|
||||||
let inputDir = payload.batchFolderPath;
|
let inputDir = payload.batchFolderPath;
|
||||||
let outputDir = payload.outputPath;
|
let outputDir = model.includes("realesrgan")
|
||||||
|
? payload.outputPath
|
||||||
|
: payload.outputPath + "_sharpened";
|
||||||
console.log(outputDir);
|
console.log(outputDir);
|
||||||
if (!fs.existsSync(outputDir)) {
|
if (!fs.existsSync(outputDir)) {
|
||||||
fs.mkdirSync(outputDir, { recursive: true });
|
fs.mkdirSync(outputDir, { recursive: true });
|
||||||
}
|
}
|
||||||
// UPSCALE
|
// UPSCALE
|
||||||
let upscayl = spawn(
|
let upscayl = null;
|
||||||
execPath("realesrgan"),
|
switch (model) {
|
||||||
["-i", inputDir, "-o", outputDir, "-s", 4, "-m", modelsPath, "-n", model],
|
case "realesrgan-x4plus":
|
||||||
{
|
case "realesrgan-x4plus-anime":
|
||||||
cwd: null,
|
upscayl = spawn(
|
||||||
detached: false,
|
execPath("realesrgan"),
|
||||||
}
|
[
|
||||||
);
|
"-i",
|
||||||
|
inputDir,
|
||||||
|
"-o",
|
||||||
|
outputDir,
|
||||||
|
"-s",
|
||||||
|
4,
|
||||||
|
"-m",
|
||||||
|
modelsPath,
|
||||||
|
"-n",
|
||||||
|
model,
|
||||||
|
],
|
||||||
|
{
|
||||||
|
cwd: null,
|
||||||
|
detached: false,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case "models-DF2K":
|
||||||
|
upscayl = spawn(
|
||||||
|
execPath("realsr"),
|
||||||
|
[
|
||||||
|
"-i",
|
||||||
|
inputDir,
|
||||||
|
"-o",
|
||||||
|
outputDir,
|
||||||
|
"-s",
|
||||||
|
4,
|
||||||
|
"-x",
|
||||||
|
"-m",
|
||||||
|
modelsPath + "/" + model,
|
||||||
|
],
|
||||||
|
{
|
||||||
|
cwd: null,
|
||||||
|
detached: false,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
let failed = false;
|
let failed = false;
|
||||||
upscayl.stderr.on("data", (data) => {
|
upscayl.stderr.on("data", (data) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user