1
0
mirror of https://github.com/upscayl/upscayl.git synced 2024-11-28 01:10:52 +01:00

Added new models

This commit is contained in:
Feenix 2022-12-02 19:51:42 +05:30
parent d2e309303f
commit 60bbb056a3
11 changed files with 4289 additions and 1414 deletions

View File

@ -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-----------------------------// //------------------------Double Upscayl-----------------------------//
ipcMain.on(commands.DOUBLE_UPSCAYL, async (event, payload) => { ipcMain.on(commands.DOUBLE_UPSCAYL, async (event, payload) => {
const model = payload.model; 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; let failed = false;
// TAKE UPSCAYL OUTPUT // TAKE UPSCAYL OUTPUT
upscayl.stderr.on("data", (data) => { upscayl.stderr.on("data", (data) => {
@ -233,16 +253,17 @@ 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 = model.includes("realesrgan") const outFile = model.includes("models-DF2K")
? outputDir + "/" + fileName + "_upscayl_" + scale + "x_" + model + fileExt ? outputDir +
: outputDir +
"/" + "/" +
fileName + fileName +
"_upscayl_sharpened_" + "_upscayl_sharpened_" +
scale + scale +
"x_" + "x_" +
model + model +
fileExt; fileExt
: outputDir + "/" + fileName + "_upscayl_" + 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
@ -250,8 +271,7 @@ ipcMain.on(commands.UPSCAYL, async (event, payload) => {
} else { } else {
let upscayl: ChildProcessWithoutNullStreams | null = null; let upscayl: ChildProcessWithoutNullStreams | null = null;
switch (model) { switch (model) {
case "realesrgan-x4plus": default:
case "realesrgan-x4plus-anime":
upscayl = spawn( upscayl = spawn(
execPath("realesrgan"), execPath("realesrgan"),
[ [
@ -271,6 +291,19 @@ ipcMain.on(commands.UPSCAYL, async (event, payload) => {
detached: false, detached: false,
} }
); );
console.log(
"🆙 COMMAND: ",
"-i",
inputDir + "/" + fullfileName,
"-o",
outFile,
"-s",
scale === 2 ? 4 : scale,
"-m",
modelsPath,
"-n",
model
);
break; break;
case "models-DF2K": case "models-DF2K":
upscayl = spawn( upscayl = spawn(
@ -291,6 +324,18 @@ ipcMain.on(commands.UPSCAYL, async (event, payload) => {
detached: false, detached: false,
} }
); );
console.log(
"🆙 COMMAND: ",
"-i",
inputDir + "/" + fullfileName,
"-o",
outFile,
"-s",
scale,
"-x",
"-m",
modelsPath + "/" + model
);
break; break;
} }
@ -421,20 +466,26 @@ ipcMain.on(commands.UPSCAYL_VIDEO, async (event, payload) => {
//------------------------Upscayl Folder-----------------------------// //------------------------Upscayl Folder-----------------------------//
ipcMain.on(commands.FOLDER_UPSCAYL, async (event, payload) => { ipcMain.on(commands.FOLDER_UPSCAYL, async (event, payload) => {
// GET THE MODEL
const model = payload.model; const model = payload.model;
// GET THE IMAGE DIRECTORY
let inputDir = payload.batchFolderPath; let inputDir = payload.batchFolderPath;
let outputDir = model.includes("realesrgan") console.log("🚀 => file: index.ts => line 471 => inputDir", inputDir);
? payload.outputPath
: payload.outputPath + "_sharpened"; // GET THE OUTPUT DIRECTORY
console.log(outputDir); let outputDir = model.includes("models-DF2K")
? payload.outputPath + "_sharpened"
: payload.outputPath;
console.log("🚀 => file: index.ts => line 474 => outputDir", outputDir);
if (!fs.existsSync(outputDir)) { if (!fs.existsSync(outputDir)) {
fs.mkdirSync(outputDir, { recursive: true }); fs.mkdirSync(outputDir, { recursive: true });
} }
// UPSCALE // UPSCALE
let upscayl: ChildProcessWithoutNullStreams | null = null; let upscayl: ChildProcessWithoutNullStreams | null = null;
switch (model) { switch (model) {
case "realesrgan-x4plus": default:
case "realesrgan-x4plus-anime":
upscayl = spawn( upscayl = spawn(
execPath("realesrgan"), execPath("realesrgan"),
[ [
@ -454,6 +505,19 @@ ipcMain.on(commands.FOLDER_UPSCAYL, async (event, payload) => {
detached: false, detached: false,
} }
); );
console.log(
"🆙 COMMAND:",
"-i",
inputDir,
"-o",
outputDir,
"-s",
4,
"-m",
modelsPath,
"-n",
model
);
break; break;
case "models-DF2K": case "models-DF2K":
upscayl = spawn( upscayl = spawn(
@ -474,6 +538,18 @@ ipcMain.on(commands.FOLDER_UPSCAYL, async (event, payload) => {
detached: false, detached: false,
} }
); );
console.log(
"🆙 COMMAND:",
"-i",
inputDir,
"-o",
outputDir,
"-s",
4,
"-x",
"-m",
modelsPath + "/" + model
);
break; 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 Code-----------------------------//
// ! AUTO UPDATE STUFF // ! AUTO UPDATE STUFF
autoUpdater.on("update-available", ({ releaseNotes, releaseName }) => { autoUpdater.on("update-available", ({ releaseNotes, releaseName }) => {

View File

@ -102,6 +102,11 @@ electron_1.ipcMain.handle(commands_1.default.SELECT_FOLDER, (event, message) =>
return filePaths[0]; 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-----------------------------// //------------------------Double Upscayl-----------------------------//
electron_1.ipcMain.on(commands_1.default.DOUBLE_UPSCAYL, (event, payload) => __awaiter(void 0, void 0, void 0, function* () { electron_1.ipcMain.on(commands_1.default.DOUBLE_UPSCAYL, (event, payload) => __awaiter(void 0, void 0, void 0, function* () {
const model = payload.model; const model = payload.model;
@ -131,6 +136,7 @@ electron_1.ipcMain.on(commands_1.default.DOUBLE_UPSCAYL, (event, payload) => __a
cwd: undefined, cwd: undefined,
detached: false, detached: false,
}); });
console.log("🆙 COMMAND:", "-i", inputDir + "/" + fullfileName, "-o", outFile, "-s", 4, "-m", binaries_1.modelsPath, "-n", model);
let failed = false; let failed = false;
// TAKE UPSCAYL OUTPUT // TAKE UPSCAYL OUTPUT
upscayl.stderr.on("data", (data) => { upscayl.stderr.on("data", (data) => {
@ -206,16 +212,16 @@ electron_1.ipcMain.on(commands_1.default.UPSCAYL, (event, payload) => __awaiter(
console.log(fullfileName); console.log(fullfileName);
const fileName = (0, path_1.parse)(fullfileName).name; const fileName = (0, path_1.parse)(fullfileName).name;
const fileExt = (0, path_1.parse)(fullfileName).ext; const fileExt = (0, path_1.parse)(fullfileName).ext;
const outFile = model.includes("realesrgan") const outFile = model.includes("models-DF2K")
? outputDir + "/" + fileName + "_upscayl_" + scale + "x_" + model + fileExt ? outputDir +
: outputDir +
"/" + "/" +
fileName + fileName +
"_upscayl_sharpened_" + "_upscayl_sharpened_" +
scale + scale +
"x_" + "x_" +
model + model +
fileExt; fileExt
: outputDir + "/" + fileName + "_upscayl_" + scale + "x_" + model + fileExt;
// UPSCALE // UPSCALE
if (fs_1.default.existsSync(outFile)) { if (fs_1.default.existsSync(outFile)) {
// If already upscayled, just output that file // If already upscayled, just output that file
@ -224,8 +230,7 @@ electron_1.ipcMain.on(commands_1.default.UPSCAYL, (event, payload) => __awaiter(
else { else {
let upscayl = null; let upscayl = null;
switch (model) { switch (model) {
case "realesrgan-x4plus": default:
case "realesrgan-x4plus-anime":
upscayl = (0, child_process_1.spawn)((0, binaries_1.execPath)("realesrgan"), [ upscayl = (0, child_process_1.spawn)((0, binaries_1.execPath)("realesrgan"), [
"-i", "-i",
inputDir + "/" + fullfileName, inputDir + "/" + fullfileName,
@ -241,6 +246,7 @@ electron_1.ipcMain.on(commands_1.default.UPSCAYL, (event, payload) => __awaiter(
cwd: undefined, cwd: undefined,
detached: false, detached: false,
}); });
console.log("🆙 COMMAND: ", "-i", inputDir + "/" + fullfileName, "-o", outFile, "-s", scale === 2 ? 4 : scale, "-m", binaries_1.modelsPath, "-n", model);
break; break;
case "models-DF2K": case "models-DF2K":
upscayl = (0, child_process_1.spawn)((0, binaries_1.execPath)("realsr"), [ 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, cwd: undefined,
detached: false, detached: false,
}); });
console.log("🆙 COMMAND: ", "-i", inputDir + "/" + fullfileName, "-o", outFile, "-s", scale, "-x", "-m", binaries_1.modelsPath + "/" + model);
break; break;
} }
let failed = false; let failed = false;
@ -308,23 +315,64 @@ electron_1.ipcMain.on(commands_1.default.UPSCAYL_VIDEO, (event, payload) => __aw
cwd: undefined, cwd: undefined,
detached: false, 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-----------------------------// //------------------------Upscayl Folder-----------------------------//
electron_1.ipcMain.on(commands_1.default.FOLDER_UPSCAYL, (event, payload) => __awaiter(void 0, void 0, void 0, function* () { 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; const model = payload.model;
// GET THE IMAGE DIRECTORY
let inputDir = payload.batchFolderPath; let inputDir = payload.batchFolderPath;
let outputDir = model.includes("realesrgan") console.log("🚀 => file: index.ts => line 471 => inputDir", inputDir);
? payload.outputPath // GET THE OUTPUT DIRECTORY
: payload.outputPath + "_sharpened"; let outputDir = model.includes("models-DF2K")
console.log(outputDir); ? payload.outputPath + "_sharpened"
: payload.outputPath;
console.log("🚀 => file: index.ts => line 474 => outputDir", outputDir);
if (!fs_1.default.existsSync(outputDir)) { if (!fs_1.default.existsSync(outputDir)) {
fs_1.default.mkdirSync(outputDir, { recursive: true }); fs_1.default.mkdirSync(outputDir, { recursive: true });
} }
// UPSCALE // UPSCALE
let upscayl = null; let upscayl = null;
switch (model) { switch (model) {
case "realesrgan-x4plus": default:
case "realesrgan-x4plus-anime":
upscayl = (0, child_process_1.spawn)((0, binaries_1.execPath)("realesrgan"), [ upscayl = (0, child_process_1.spawn)((0, binaries_1.execPath)("realesrgan"), [
"-i", "-i",
inputDir, inputDir,
@ -340,6 +388,7 @@ electron_1.ipcMain.on(commands_1.default.FOLDER_UPSCAYL, (event, payload) => __a
cwd: undefined, cwd: undefined,
detached: false, detached: false,
}); });
console.log("🆙 COMMAND:", "-i", inputDir, "-o", outputDir, "-s", 4, "-m", binaries_1.modelsPath, "-n", model);
break; break;
case "models-DF2K": case "models-DF2K":
upscayl = (0, child_process_1.spawn)((0, binaries_1.execPath)("realsr"), [ 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, cwd: undefined,
detached: false, detached: false,
}); });
console.log("🆙 COMMAND:", "-i", inputDir, "-o", outputDir, "-s", 4, "-x", "-m", binaries_1.modelsPath + "/" + model);
break; break;
} }
let failed = false; 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 Code-----------------------------//
// ! AUTO UPDATE STUFF // ! AUTO UPDATE STUFF
electron_updater_1.autoUpdater.on("update-available", ({ releaseNotes, releaseName }) => { electron_updater_1.autoUpdater.on("update-available", ({ releaseNotes, releaseName }) => {

View File

@ -63,7 +63,10 @@ function LeftPaneImageSteps({
}; };
const modelOptions = [ 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: "Digital Art", value: "realesrgan-x4plus-anime" },
{ label: "Sharpen Image", value: "models-DF2K" }, { label: "Sharpen Image", value: "models-DF2K" },
]; ];

View File

@ -2,16 +2,17 @@ import React from "react";
import Animated from "../public/loading.svg"; import Animated from "../public/loading.svg";
import Image from "next/image"; import Image from "next/image";
function ProgressBar(props) { function ProgressBar({ progress, doubleUpscaylCounter }) {
console.log(props.sharpening);
return ( return (
<div className="absolute flex h-full w-full flex-col items-center justify-center bg-black/50 backdrop-blur-lg"> <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"> <div className="flex flex-col items-center gap-2">
<Image src={Animated} alt="Progress Bar" /> <Image src={Animated} alt="Progress Bar" />
<p className="font-bold text-neutral-50">{props.progress}</p> <p className="font-bold">
<p className="text-sm font-medium text-neutral-200"> {doubleUpscaylCounter > 0
Doing the Upscayl magic... ? `${progress}\nPass ${doubleUpscaylCounter}`
: `${progress}`}
</p> </p>
<p className="text-sm font-medium">Doing the Upscayl magic...</p>
</div> </div>
</div> </div>
); );

View File

@ -20,7 +20,7 @@ const Home = () => {
const [outputPath, setOutputPath] = useState(""); const [outputPath, setOutputPath] = useState("");
const [scaleFactor, setScaleFactor] = useState(4); const [scaleFactor, setScaleFactor] = useState(4);
const [progress, setProgress] = useState(""); const [progress, setProgress] = useState("");
const [model, setModel] = useState("realesrgan-x4plus"); const [model, setModel] = useState("remacri");
const [loaded, setLoaded] = useState(false); const [loaded, setLoaded] = useState(false);
const [version, setVersion] = useState(""); const [version, setVersion] = useState("");
const [batchMode, setBatchMode] = useState(false); const [batchMode, setBatchMode] = useState(false);
@ -30,6 +30,7 @@ const Home = () => {
const [isVideo, setIsVideo] = useState(false); const [isVideo, setIsVideo] = useState(false);
const [videoPath, setVideoPath] = useState(""); const [videoPath, setVideoPath] = useState("");
const [upscaledVideoPath, setUpscaledVideoPath] = useState(""); const [upscaledVideoPath, setUpscaledVideoPath] = useState("");
const [doubleUpscaylCounter, setDoubleUpscaylCounter] = useState(0);
const resetImagePaths = () => { const resetImagePaths = () => {
setProgress(""); setProgress("");
@ -91,6 +92,9 @@ const Home = () => {
}); });
window.electron.on(commands.DOUBLE_UPSCAYL_PROGRESS, (_, data) => { window.electron.on(commands.DOUBLE_UPSCAYL_PROGRESS, (_, data) => {
if (data.length > 0 && data.length < 10) { if (data.length > 0 && data.length < 10) {
if (data === "0.00%") {
setDoubleUpscaylCounter(doubleUpscaylCounter + 1);
}
setProgress(data); setProgress(data);
} }
handleErrors(data); handleErrors(data);
@ -111,9 +115,12 @@ const Home = () => {
setUpscaledBatchFolderPath(data); setUpscaledBatchFolderPath(data);
}); });
window.electron.on(commands.DOUBLE_UPSCAYL_DONE, (_, data) => { window.electron.on(commands.DOUBLE_UPSCAYL_DONE, (_, data) => {
setProgress("");
setDoubleUpscaylCounter(0);
setUpscaledImagePath(data); setUpscaledImagePath(data);
}); });
window.electron.on(commands.UPSCAYL_VIDEO_DONE, (_, data) => { window.electron.on(commands.UPSCAYL_VIDEO_DONE, (_, data) => {
setProgress("");
setUpscaledVideoPath(data); setUpscaledVideoPath(data);
}); });
}, []); }, []);
@ -407,7 +414,10 @@ const Home = () => {
upscaledImagePath.length === 0 && upscaledImagePath.length === 0 &&
upscaledBatchFolderPath.length === 0 && upscaledBatchFolderPath.length === 0 &&
upscaledVideoPath.length === 0 ? ( upscaledVideoPath.length === 0 ? (
<ProgressBar progress={progress} /> <ProgressBar
progress={progress}
doubleUpscaylCounter={doubleUpscaylCounter}
/>
) : null} ) : null}
{/* DEFAULT PANE INFO */} {/* DEFAULT PANE INFO */}
@ -502,7 +512,7 @@ const Home = () => {
style={{ style={{
objectFit: "contain", objectFit: "contain",
}} }}
className="origin-bottom scale-[200%] bg-[#1d1c23]" className="bg-[#1d1c23]"
/> />
</> </>
} }

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff