mirror of
https://github.com/upscayl/upscayl.git
synced 2025-02-07 23:11:27 +01:00
added sharpen mode for normal and batch mode
This commit is contained in:
parent
39b42aca9c
commit
b8ee88ebb3
@ -231,14 +231,26 @@ 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;
|
||||||
|
switch (model) {
|
||||||
|
case "realesrgan-x4plus":
|
||||||
|
case "realesrgan-x4plus-anime":
|
||||||
|
upscayl = spawn(
|
||||||
execPath("realesrgan"),
|
execPath("realesrgan"),
|
||||||
[
|
[
|
||||||
"-i",
|
"-i",
|
||||||
@ -257,6 +269,28 @@ ipcMain.on(commands.UPSCAYL, async (event, payload) => {
|
|||||||
detached: false,
|
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;
|
||||||
|
switch (model) {
|
||||||
|
case "realesrgan-x4plus":
|
||||||
|
case "realesrgan-x4plus-anime":
|
||||||
|
upscayl = spawn(
|
||||||
execPath("realesrgan"),
|
execPath("realesrgan"),
|
||||||
["-i", inputDir, "-o", outputDir, "-s", 4, "-m", modelsPath, "-n", model],
|
[
|
||||||
|
"-i",
|
||||||
|
inputDir,
|
||||||
|
"-o",
|
||||||
|
outputDir,
|
||||||
|
"-s",
|
||||||
|
4,
|
||||||
|
"-m",
|
||||||
|
modelsPath,
|
||||||
|
"-n",
|
||||||
|
model,
|
||||||
|
],
|
||||||
{
|
{
|
||||||
cwd: null,
|
cwd: null,
|
||||||
detached: false,
|
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