mirror of
https://github.com/upscayl/upscayl.git
synced 2024-11-23 23:21:05 +01:00
Added new models
This commit is contained in:
parent
d2e309303f
commit
60bbb056a3
@ -109,6 +109,12 @@ ipcMain.handle(commands.SELECT_FOLDER, async (event, message) => {
|
||||
}
|
||||
});
|
||||
|
||||
//------------------------Open Folder-----------------------------//
|
||||
ipcMain.on(commands.OPEN_FOLDER, async (event, payload) => {
|
||||
console.log(payload);
|
||||
shell.openPath(payload);
|
||||
});
|
||||
|
||||
//------------------------Double Upscayl-----------------------------//
|
||||
ipcMain.on(commands.DOUBLE_UPSCAYL, async (event, payload) => {
|
||||
const model = payload.model;
|
||||
@ -146,6 +152,20 @@ ipcMain.on(commands.DOUBLE_UPSCAYL, async (event, payload) => {
|
||||
}
|
||||
);
|
||||
|
||||
console.log(
|
||||
"🆙 COMMAND:",
|
||||
"-i",
|
||||
inputDir + "/" + fullfileName,
|
||||
"-o",
|
||||
outFile,
|
||||
"-s",
|
||||
4,
|
||||
"-m",
|
||||
modelsPath,
|
||||
"-n",
|
||||
model
|
||||
);
|
||||
|
||||
let failed = false;
|
||||
// TAKE UPSCAYL OUTPUT
|
||||
upscayl.stderr.on("data", (data) => {
|
||||
@ -233,16 +253,17 @@ ipcMain.on(commands.UPSCAYL, async (event, payload) => {
|
||||
console.log(fullfileName);
|
||||
const fileName = parse(fullfileName).name;
|
||||
const fileExt = parse(fullfileName).ext;
|
||||
const outFile = model.includes("realesrgan")
|
||||
? outputDir + "/" + fileName + "_upscayl_" + scale + "x_" + model + fileExt
|
||||
: outputDir +
|
||||
const outFile = model.includes("models-DF2K")
|
||||
? outputDir +
|
||||
"/" +
|
||||
fileName +
|
||||
"_upscayl_sharpened_" +
|
||||
scale +
|
||||
"x_" +
|
||||
model +
|
||||
fileExt;
|
||||
fileExt
|
||||
: outputDir + "/" + fileName + "_upscayl_" + scale + "x_" + model + fileExt;
|
||||
|
||||
// UPSCALE
|
||||
if (fs.existsSync(outFile)) {
|
||||
// If already upscayled, just output that file
|
||||
@ -250,8 +271,7 @@ ipcMain.on(commands.UPSCAYL, async (event, payload) => {
|
||||
} else {
|
||||
let upscayl: ChildProcessWithoutNullStreams | null = null;
|
||||
switch (model) {
|
||||
case "realesrgan-x4plus":
|
||||
case "realesrgan-x4plus-anime":
|
||||
default:
|
||||
upscayl = spawn(
|
||||
execPath("realesrgan"),
|
||||
[
|
||||
@ -271,6 +291,19 @@ ipcMain.on(commands.UPSCAYL, async (event, payload) => {
|
||||
detached: false,
|
||||
}
|
||||
);
|
||||
console.log(
|
||||
"🆙 COMMAND: ",
|
||||
"-i",
|
||||
inputDir + "/" + fullfileName,
|
||||
"-o",
|
||||
outFile,
|
||||
"-s",
|
||||
scale === 2 ? 4 : scale,
|
||||
"-m",
|
||||
modelsPath,
|
||||
"-n",
|
||||
model
|
||||
);
|
||||
break;
|
||||
case "models-DF2K":
|
||||
upscayl = spawn(
|
||||
@ -291,6 +324,18 @@ ipcMain.on(commands.UPSCAYL, async (event, payload) => {
|
||||
detached: false,
|
||||
}
|
||||
);
|
||||
console.log(
|
||||
"🆙 COMMAND: ",
|
||||
"-i",
|
||||
inputDir + "/" + fullfileName,
|
||||
"-o",
|
||||
outFile,
|
||||
"-s",
|
||||
scale,
|
||||
"-x",
|
||||
"-m",
|
||||
modelsPath + "/" + model
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -421,20 +466,26 @@ ipcMain.on(commands.UPSCAYL_VIDEO, async (event, payload) => {
|
||||
|
||||
//------------------------Upscayl Folder-----------------------------//
|
||||
ipcMain.on(commands.FOLDER_UPSCAYL, async (event, payload) => {
|
||||
// GET THE MODEL
|
||||
const model = payload.model;
|
||||
|
||||
// GET THE IMAGE DIRECTORY
|
||||
let inputDir = payload.batchFolderPath;
|
||||
let outputDir = model.includes("realesrgan")
|
||||
? payload.outputPath
|
||||
: payload.outputPath + "_sharpened";
|
||||
console.log(outputDir);
|
||||
console.log("🚀 => file: index.ts => line 471 => inputDir", inputDir);
|
||||
|
||||
// GET THE OUTPUT DIRECTORY
|
||||
let outputDir = model.includes("models-DF2K")
|
||||
? payload.outputPath + "_sharpened"
|
||||
: payload.outputPath;
|
||||
console.log("🚀 => file: index.ts => line 474 => outputDir", outputDir);
|
||||
|
||||
if (!fs.existsSync(outputDir)) {
|
||||
fs.mkdirSync(outputDir, { recursive: true });
|
||||
}
|
||||
// UPSCALE
|
||||
let upscayl: ChildProcessWithoutNullStreams | null = null;
|
||||
switch (model) {
|
||||
case "realesrgan-x4plus":
|
||||
case "realesrgan-x4plus-anime":
|
||||
default:
|
||||
upscayl = spawn(
|
||||
execPath("realesrgan"),
|
||||
[
|
||||
@ -454,6 +505,19 @@ ipcMain.on(commands.FOLDER_UPSCAYL, async (event, payload) => {
|
||||
detached: false,
|
||||
}
|
||||
);
|
||||
console.log(
|
||||
"🆙 COMMAND:",
|
||||
"-i",
|
||||
inputDir,
|
||||
"-o",
|
||||
outputDir,
|
||||
"-s",
|
||||
4,
|
||||
"-m",
|
||||
modelsPath,
|
||||
"-n",
|
||||
model
|
||||
);
|
||||
break;
|
||||
case "models-DF2K":
|
||||
upscayl = spawn(
|
||||
@ -474,6 +538,18 @@ ipcMain.on(commands.FOLDER_UPSCAYL, async (event, payload) => {
|
||||
detached: false,
|
||||
}
|
||||
);
|
||||
console.log(
|
||||
"🆙 COMMAND:",
|
||||
"-i",
|
||||
inputDir,
|
||||
"-o",
|
||||
outputDir,
|
||||
"-s",
|
||||
4,
|
||||
"-x",
|
||||
"-m",
|
||||
modelsPath + "/" + model
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -511,11 +587,6 @@ ipcMain.on(commands.FOLDER_UPSCAYL, async (event, payload) => {
|
||||
});
|
||||
});
|
||||
|
||||
ipcMain.on(commands.OPEN_FOLDER, async (event, payload) => {
|
||||
console.log(payload);
|
||||
shell.openPath(payload);
|
||||
});
|
||||
|
||||
//------------------------Auto-Update Code-----------------------------//
|
||||
// ! AUTO UPDATE STUFF
|
||||
autoUpdater.on("update-available", ({ releaseNotes, releaseName }) => {
|
||||
|
@ -102,6 +102,11 @@ electron_1.ipcMain.handle(commands_1.default.SELECT_FOLDER, (event, message) =>
|
||||
return filePaths[0];
|
||||
}
|
||||
}));
|
||||
//------------------------Open Folder-----------------------------//
|
||||
electron_1.ipcMain.on(commands_1.default.OPEN_FOLDER, (event, payload) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
console.log(payload);
|
||||
electron_1.shell.openPath(payload);
|
||||
}));
|
||||
//------------------------Double Upscayl-----------------------------//
|
||||
electron_1.ipcMain.on(commands_1.default.DOUBLE_UPSCAYL, (event, payload) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const model = payload.model;
|
||||
@ -131,6 +136,7 @@ electron_1.ipcMain.on(commands_1.default.DOUBLE_UPSCAYL, (event, payload) => __a
|
||||
cwd: undefined,
|
||||
detached: false,
|
||||
});
|
||||
console.log("🆙 COMMAND:", "-i", inputDir + "/" + fullfileName, "-o", outFile, "-s", 4, "-m", binaries_1.modelsPath, "-n", model);
|
||||
let failed = false;
|
||||
// TAKE UPSCAYL OUTPUT
|
||||
upscayl.stderr.on("data", (data) => {
|
||||
@ -206,16 +212,16 @@ electron_1.ipcMain.on(commands_1.default.UPSCAYL, (event, payload) => __awaiter(
|
||||
console.log(fullfileName);
|
||||
const fileName = (0, path_1.parse)(fullfileName).name;
|
||||
const fileExt = (0, path_1.parse)(fullfileName).ext;
|
||||
const outFile = model.includes("realesrgan")
|
||||
? outputDir + "/" + fileName + "_upscayl_" + scale + "x_" + model + fileExt
|
||||
: outputDir +
|
||||
const outFile = model.includes("models-DF2K")
|
||||
? outputDir +
|
||||
"/" +
|
||||
fileName +
|
||||
"_upscayl_sharpened_" +
|
||||
scale +
|
||||
"x_" +
|
||||
model +
|
||||
fileExt;
|
||||
fileExt
|
||||
: outputDir + "/" + fileName + "_upscayl_" + scale + "x_" + model + fileExt;
|
||||
// UPSCALE
|
||||
if (fs_1.default.existsSync(outFile)) {
|
||||
// If already upscayled, just output that file
|
||||
@ -224,8 +230,7 @@ electron_1.ipcMain.on(commands_1.default.UPSCAYL, (event, payload) => __awaiter(
|
||||
else {
|
||||
let upscayl = null;
|
||||
switch (model) {
|
||||
case "realesrgan-x4plus":
|
||||
case "realesrgan-x4plus-anime":
|
||||
default:
|
||||
upscayl = (0, child_process_1.spawn)((0, binaries_1.execPath)("realesrgan"), [
|
||||
"-i",
|
||||
inputDir + "/" + fullfileName,
|
||||
@ -241,6 +246,7 @@ electron_1.ipcMain.on(commands_1.default.UPSCAYL, (event, payload) => __awaiter(
|
||||
cwd: undefined,
|
||||
detached: false,
|
||||
});
|
||||
console.log("🆙 COMMAND: ", "-i", inputDir + "/" + fullfileName, "-o", outFile, "-s", scale === 2 ? 4 : scale, "-m", binaries_1.modelsPath, "-n", model);
|
||||
break;
|
||||
case "models-DF2K":
|
||||
upscayl = (0, child_process_1.spawn)((0, binaries_1.execPath)("realsr"), [
|
||||
@ -257,6 +263,7 @@ electron_1.ipcMain.on(commands_1.default.UPSCAYL, (event, payload) => __awaiter(
|
||||
cwd: undefined,
|
||||
detached: false,
|
||||
});
|
||||
console.log("🆙 COMMAND: ", "-i", inputDir + "/" + fullfileName, "-o", outFile, "-s", scale, "-x", "-m", binaries_1.modelsPath + "/" + model);
|
||||
break;
|
||||
}
|
||||
let failed = false;
|
||||
@ -308,23 +315,64 @@ electron_1.ipcMain.on(commands_1.default.UPSCAYL_VIDEO, (event, payload) => __aw
|
||||
cwd: undefined,
|
||||
detached: false,
|
||||
});
|
||||
// UPSCALE
|
||||
let upscayl = null;
|
||||
upscayl = (0, child_process_1.spawn)((0, binaries_1.execPath)("realesrgan"), [
|
||||
"-i",
|
||||
frameExtractionPath,
|
||||
"-o",
|
||||
frameExtractionPath + "_upscaled",
|
||||
"-s",
|
||||
4,
|
||||
"-m",
|
||||
binaries_1.modelsPath,
|
||||
"-n",
|
||||
model,
|
||||
], {
|
||||
cwd: undefined,
|
||||
detached: false,
|
||||
});
|
||||
let failed = false;
|
||||
upscayl === null || upscayl === void 0 ? void 0 : upscayl.stderr.on("data", (data) => {
|
||||
console.log("🚀 => upscayl.stderr.on => stderr.toString()", data.toString());
|
||||
data = data.toString();
|
||||
mainWindow.webContents.send(commands_1.default.UPSCAYL_VIDEO_PROGRESS, data.toString());
|
||||
if (data.includes("invalid gpu") || data.includes("failed")) {
|
||||
failed = true;
|
||||
}
|
||||
});
|
||||
upscayl === null || upscayl === void 0 ? void 0 : upscayl.on("error", (data) => {
|
||||
mainWindow.webContents.send(commands_1.default.UPSCAYL_VIDEO_PROGRESS, data.toString());
|
||||
failed = true;
|
||||
return;
|
||||
});
|
||||
// Send done comamnd when
|
||||
upscayl === null || upscayl === void 0 ? void 0 : upscayl.on("close", (code) => {
|
||||
if (failed !== true) {
|
||||
console.log("Done upscaling");
|
||||
mainWindow.webContents.send(commands_1.default.UPSCAYL_VIDEO_DONE, outputDir);
|
||||
}
|
||||
});
|
||||
}));
|
||||
//------------------------Upscayl Folder-----------------------------//
|
||||
electron_1.ipcMain.on(commands_1.default.FOLDER_UPSCAYL, (event, payload) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
// GET THE MODEL
|
||||
const model = payload.model;
|
||||
// GET THE IMAGE DIRECTORY
|
||||
let inputDir = payload.batchFolderPath;
|
||||
let outputDir = model.includes("realesrgan")
|
||||
? payload.outputPath
|
||||
: payload.outputPath + "_sharpened";
|
||||
console.log(outputDir);
|
||||
console.log("🚀 => file: index.ts => line 471 => inputDir", inputDir);
|
||||
// GET THE OUTPUT DIRECTORY
|
||||
let outputDir = model.includes("models-DF2K")
|
||||
? payload.outputPath + "_sharpened"
|
||||
: payload.outputPath;
|
||||
console.log("🚀 => file: index.ts => line 474 => outputDir", outputDir);
|
||||
if (!fs_1.default.existsSync(outputDir)) {
|
||||
fs_1.default.mkdirSync(outputDir, { recursive: true });
|
||||
}
|
||||
// UPSCALE
|
||||
let upscayl = null;
|
||||
switch (model) {
|
||||
case "realesrgan-x4plus":
|
||||
case "realesrgan-x4plus-anime":
|
||||
default:
|
||||
upscayl = (0, child_process_1.spawn)((0, binaries_1.execPath)("realesrgan"), [
|
||||
"-i",
|
||||
inputDir,
|
||||
@ -340,6 +388,7 @@ electron_1.ipcMain.on(commands_1.default.FOLDER_UPSCAYL, (event, payload) => __a
|
||||
cwd: undefined,
|
||||
detached: false,
|
||||
});
|
||||
console.log("🆙 COMMAND:", "-i", inputDir, "-o", outputDir, "-s", 4, "-m", binaries_1.modelsPath, "-n", model);
|
||||
break;
|
||||
case "models-DF2K":
|
||||
upscayl = (0, child_process_1.spawn)((0, binaries_1.execPath)("realsr"), [
|
||||
@ -356,6 +405,7 @@ electron_1.ipcMain.on(commands_1.default.FOLDER_UPSCAYL, (event, payload) => __a
|
||||
cwd: undefined,
|
||||
detached: false,
|
||||
});
|
||||
console.log("🆙 COMMAND:", "-i", inputDir, "-o", outputDir, "-s", 4, "-x", "-m", binaries_1.modelsPath + "/" + model);
|
||||
break;
|
||||
}
|
||||
let failed = false;
|
||||
@ -380,10 +430,6 @@ electron_1.ipcMain.on(commands_1.default.FOLDER_UPSCAYL, (event, payload) => __a
|
||||
}
|
||||
});
|
||||
}));
|
||||
electron_1.ipcMain.on(commands_1.default.OPEN_FOLDER, (event, payload) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
console.log(payload);
|
||||
electron_1.shell.openPath(payload);
|
||||
}));
|
||||
//------------------------Auto-Update Code-----------------------------//
|
||||
// ! AUTO UPDATE STUFF
|
||||
electron_updater_1.autoUpdater.on("update-available", ({ releaseNotes, releaseName }) => {
|
||||
|
@ -63,7 +63,10 @@ function LeftPaneImageSteps({
|
||||
};
|
||||
|
||||
const modelOptions = [
|
||||
{ label: "General Photo", value: "realesrgan-x4plus" },
|
||||
{ label: "General Photo (Remacri)", value: "remacri" },
|
||||
{ label: "General Photo (Ultramix Balanced)", value: "ultramix_balanced" },
|
||||
{ label: "General Photo (Real-ESRGAN)", value: "realesrgan-x4plus" },
|
||||
{ label: "General Photo (Ultrasharp)", value: "ultrasharp" },
|
||||
{ label: "Digital Art", value: "realesrgan-x4plus-anime" },
|
||||
{ label: "Sharpen Image", value: "models-DF2K" },
|
||||
];
|
||||
|
@ -2,16 +2,17 @@ import React from "react";
|
||||
import Animated from "../public/loading.svg";
|
||||
import Image from "next/image";
|
||||
|
||||
function ProgressBar(props) {
|
||||
console.log(props.sharpening);
|
||||
function ProgressBar({ progress, doubleUpscaylCounter }) {
|
||||
return (
|
||||
<div className="absolute flex h-full w-full flex-col items-center justify-center bg-black/50 backdrop-blur-lg">
|
||||
<div className="flex flex-col items-center gap-2">
|
||||
<Image src={Animated} alt="Progress Bar" />
|
||||
<p className="font-bold text-neutral-50">{props.progress}</p>
|
||||
<p className="text-sm font-medium text-neutral-200">
|
||||
Doing the Upscayl magic...
|
||||
<p className="font-bold">
|
||||
{doubleUpscaylCounter > 0
|
||||
? `${progress}\nPass ${doubleUpscaylCounter}`
|
||||
: `${progress}`}
|
||||
</p>
|
||||
<p className="text-sm font-medium">Doing the Upscayl magic...</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
@ -20,7 +20,7 @@ const Home = () => {
|
||||
const [outputPath, setOutputPath] = useState("");
|
||||
const [scaleFactor, setScaleFactor] = useState(4);
|
||||
const [progress, setProgress] = useState("");
|
||||
const [model, setModel] = useState("realesrgan-x4plus");
|
||||
const [model, setModel] = useState("remacri");
|
||||
const [loaded, setLoaded] = useState(false);
|
||||
const [version, setVersion] = useState("");
|
||||
const [batchMode, setBatchMode] = useState(false);
|
||||
@ -30,6 +30,7 @@ const Home = () => {
|
||||
const [isVideo, setIsVideo] = useState(false);
|
||||
const [videoPath, setVideoPath] = useState("");
|
||||
const [upscaledVideoPath, setUpscaledVideoPath] = useState("");
|
||||
const [doubleUpscaylCounter, setDoubleUpscaylCounter] = useState(0);
|
||||
|
||||
const resetImagePaths = () => {
|
||||
setProgress("");
|
||||
@ -91,6 +92,9 @@ const Home = () => {
|
||||
});
|
||||
window.electron.on(commands.DOUBLE_UPSCAYL_PROGRESS, (_, data) => {
|
||||
if (data.length > 0 && data.length < 10) {
|
||||
if (data === "0.00%") {
|
||||
setDoubleUpscaylCounter(doubleUpscaylCounter + 1);
|
||||
}
|
||||
setProgress(data);
|
||||
}
|
||||
handleErrors(data);
|
||||
@ -111,9 +115,12 @@ const Home = () => {
|
||||
setUpscaledBatchFolderPath(data);
|
||||
});
|
||||
window.electron.on(commands.DOUBLE_UPSCAYL_DONE, (_, data) => {
|
||||
setProgress("");
|
||||
setDoubleUpscaylCounter(0);
|
||||
setUpscaledImagePath(data);
|
||||
});
|
||||
window.electron.on(commands.UPSCAYL_VIDEO_DONE, (_, data) => {
|
||||
setProgress("");
|
||||
setUpscaledVideoPath(data);
|
||||
});
|
||||
}, []);
|
||||
@ -407,7 +414,10 @@ const Home = () => {
|
||||
upscaledImagePath.length === 0 &&
|
||||
upscaledBatchFolderPath.length === 0 &&
|
||||
upscaledVideoPath.length === 0 ? (
|
||||
<ProgressBar progress={progress} />
|
||||
<ProgressBar
|
||||
progress={progress}
|
||||
doubleUpscaylCounter={doubleUpscaylCounter}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
{/* DEFAULT PANE INFO */}
|
||||
@ -502,7 +512,7 @@ const Home = () => {
|
||||
style={{
|
||||
objectFit: "contain",
|
||||
}}
|
||||
className="origin-bottom scale-[200%] bg-[#1d1c23]"
|
||||
className="bg-[#1d1c23]"
|
||||
/>
|
||||
</>
|
||||
}
|
||||
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
BIN
resources/models/ultramix_balanced.bin
Normal file
BIN
resources/models/ultramix_balanced.bin
Normal file
Binary file not shown.
1372
resources/models/ultramix_balanced.param
Normal file
1372
resources/models/ultramix_balanced.param
Normal file
File diff suppressed because it is too large
Load Diff
BIN
resources/models/ultrasharp.bin
Normal file
BIN
resources/models/ultrasharp.bin
Normal file
Binary file not shown.
1372
resources/models/ultrasharp.param
Normal file
1372
resources/models/ultrasharp.param
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user