mirror of
https://github.com/upscayl/upscayl.git
synced 2024-11-23 23:21:05 +01:00
Added scale
This commit is contained in:
parent
abd7063cb3
commit
bfc909e99d
@ -79,6 +79,14 @@ electron_log_1.default.log(electron_1.app.getAppPath());
|
|||||||
let imagePath = undefined;
|
let imagePath = undefined;
|
||||||
let folderPath = undefined;
|
let folderPath = undefined;
|
||||||
let customModelsFolderPath = undefined;
|
let customModelsFolderPath = undefined;
|
||||||
|
// Default models
|
||||||
|
const defaultModels = [
|
||||||
|
"realesrgan-x4plus",
|
||||||
|
"remacri",
|
||||||
|
"ultramix_balanced",
|
||||||
|
"ultrasharp",
|
||||||
|
"realesrgan-x4plus-anime",
|
||||||
|
];
|
||||||
//------------------------Select File-----------------------------//
|
//------------------------Select File-----------------------------//
|
||||||
// ! DONT FORGET TO RESTART THE APP WHEN YOU CHANGE CODE HERE
|
// ! DONT FORGET TO RESTART THE APP WHEN YOU CHANGE CODE HERE
|
||||||
electron_1.ipcMain.handle(commands_1.default.SELECT_FILE, () => __awaiter(void 0, void 0, void 0, function* () {
|
electron_1.ipcMain.handle(commands_1.default.SELECT_FILE, () => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
@ -169,6 +177,7 @@ const getModels = (folderPath) => {
|
|||||||
};
|
};
|
||||||
electron_1.ipcMain.on(commands_1.default.GET_MODELS_LIST, (event, payload) => __awaiter(void 0, void 0, void 0, function* () {
|
electron_1.ipcMain.on(commands_1.default.GET_MODELS_LIST, (event, payload) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
if (payload) {
|
if (payload) {
|
||||||
|
customModelsFolderPath = payload;
|
||||||
mainWindow.webContents.send(commands_1.default.CUSTOM_MODEL_FILES_LIST, getModels(payload));
|
mainWindow.webContents.send(commands_1.default.CUSTOM_MODEL_FILES_LIST, getModels(payload));
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
@ -201,6 +210,7 @@ electron_1.ipcMain.on(commands_1.default.DOUBLE_UPSCAYL, (event, payload) => __a
|
|||||||
let outputDir = payload.outputPath;
|
let outputDir = payload.outputPath;
|
||||||
const gpuId = payload.gpuId;
|
const gpuId = payload.gpuId;
|
||||||
const saveImageAs = payload.saveImageAs;
|
const saveImageAs = payload.saveImageAs;
|
||||||
|
const isDefaultModel = defaultModels.includes(model);
|
||||||
// COPY IMAGE TO TMP FOLDER
|
// COPY IMAGE TO TMP FOLDER
|
||||||
const platform = (0, getPlatform_1.default)();
|
const platform = (0, getPlatform_1.default)();
|
||||||
const fullfileName = platform === "win"
|
const fullfileName = platform === "win"
|
||||||
@ -210,7 +220,7 @@ electron_1.ipcMain.on(commands_1.default.DOUBLE_UPSCAYL, (event, payload) => __a
|
|||||||
const fileExt = (0, path_1.parse)(fullfileName).ext;
|
const fileExt = (0, path_1.parse)(fullfileName).ext;
|
||||||
const outFile = outputDir + "/" + fileName + "_upscayl_16x_" + model + "." + saveImageAs;
|
const outFile = outputDir + "/" + fileName + "_upscayl_16x_" + model + "." + saveImageAs;
|
||||||
// UPSCALE
|
// UPSCALE
|
||||||
let upscayl = (0, upscayl_1.spawnUpscayl)("realesrgan", (0, getArguments_1.getDoubleUpscaleArguments)(inputDir, fullfileName, outFile, binaries_1.modelsPath, model, gpuId, saveImageAs));
|
let upscayl = (0, upscayl_1.spawnUpscayl)("realesrgan", (0, getArguments_1.getDoubleUpscaleArguments)(inputDir, fullfileName, outFile, isDefaultModel ? binaries_1.modelsPath : customModelsFolderPath !== null && customModelsFolderPath !== void 0 ? customModelsFolderPath : binaries_1.modelsPath, model, gpuId, saveImageAs));
|
||||||
let failed = false;
|
let failed = false;
|
||||||
let isAlpha = false;
|
let isAlpha = false;
|
||||||
let failed2 = false;
|
let failed2 = false;
|
||||||
@ -269,7 +279,7 @@ electron_1.ipcMain.on(commands_1.default.DOUBLE_UPSCAYL, (event, payload) => __a
|
|||||||
// IF NOT FAILED
|
// IF NOT FAILED
|
||||||
if (!failed) {
|
if (!failed) {
|
||||||
// UPSCALE
|
// UPSCALE
|
||||||
let upscayl2 = (0, upscayl_1.spawnUpscayl)("realesrgan", (0, getArguments_1.getDoubleUpscaleSecondPassArguments)(isAlpha, outFile, binaries_1.modelsPath, model, gpuId, saveImageAs));
|
let upscayl2 = (0, upscayl_1.spawnUpscayl)("realesrgan", (0, getArguments_1.getDoubleUpscaleSecondPassArguments)(isAlpha, outFile, isDefaultModel ? binaries_1.modelsPath : customModelsFolderPath !== null && customModelsFolderPath !== void 0 ? customModelsFolderPath : binaries_1.modelsPath, model, gpuId, saveImageAs));
|
||||||
upscayl2.process.stderr.on("data", onData2);
|
upscayl2.process.stderr.on("data", onData2);
|
||||||
upscayl2.process.on("error", onError2);
|
upscayl2.process.on("error", onError2);
|
||||||
upscayl2.process.on("close", onClose2);
|
upscayl2.process.on("close", onClose2);
|
||||||
@ -284,6 +294,7 @@ electron_1.ipcMain.on(commands_1.default.UPSCAYL, (event, payload) => __awaiter(
|
|||||||
const saveImageAs = payload.saveImageAs;
|
const saveImageAs = payload.saveImageAs;
|
||||||
let inputDir = (payload.imagePath.match(/(.*)[\/\\]/)[1] || "");
|
let inputDir = (payload.imagePath.match(/(.*)[\/\\]/)[1] || "");
|
||||||
let outputDir = payload.outputPath;
|
let outputDir = payload.outputPath;
|
||||||
|
const isDefaultModel = defaultModels.includes(model);
|
||||||
// COPY IMAGE TO TMP FOLDER
|
// COPY IMAGE TO TMP FOLDER
|
||||||
const fullfileName = payload.imagePath.replace(/^.*[\\\/]/, "");
|
const fullfileName = payload.imagePath.replace(/^.*[\\\/]/, "");
|
||||||
const fileName = (0, path_1.parse)(fullfileName).name;
|
const fileName = (0, path_1.parse)(fullfileName).name;
|
||||||
@ -305,7 +316,7 @@ electron_1.ipcMain.on(commands_1.default.UPSCAYL, (event, payload) => __awaiter(
|
|||||||
mainWindow.webContents.send(commands_1.default.UPSCAYL_DONE, outFile);
|
mainWindow.webContents.send(commands_1.default.UPSCAYL_DONE, outFile);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const upscayl = (0, upscayl_1.spawnUpscayl)("realesrgan", (0, getArguments_1.getSingleImageArguments)(inputDir, fullfileName, outFile, binaries_1.modelsPath, model, scale, gpuId, saveImageAs));
|
const upscayl = (0, upscayl_1.spawnUpscayl)("realesrgan", (0, getArguments_1.getSingleImageArguments)(inputDir, fullfileName, outFile, isDefaultModel ? binaries_1.modelsPath : customModelsFolderPath !== null && customModelsFolderPath !== void 0 ? customModelsFolderPath : binaries_1.modelsPath, model, scale, gpuId, saveImageAs));
|
||||||
let isAlpha = false;
|
let isAlpha = false;
|
||||||
let failed = false;
|
let failed = false;
|
||||||
const onData = (data) => {
|
const onData = (data) => {
|
||||||
@ -349,8 +360,9 @@ electron_1.ipcMain.on(commands_1.default.FOLDER_UPSCAYL, (event, payload) => __a
|
|||||||
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 });
|
||||||
}
|
}
|
||||||
|
const isDefaultModel = defaultModels.includes(model);
|
||||||
// UPSCALE
|
// UPSCALE
|
||||||
const upscayl = (0, upscayl_1.spawnUpscayl)("realesrgan", (0, getArguments_1.getBatchArguments)(inputDir, outputDir, binaries_1.modelsPath, model, gpuId, saveImageAs));
|
const upscayl = (0, upscayl_1.spawnUpscayl)("realesrgan", (0, getArguments_1.getBatchArguments)(inputDir, outputDir, isDefaultModel ? binaries_1.modelsPath : customModelsFolderPath !== null && customModelsFolderPath !== void 0 ? customModelsFolderPath : binaries_1.modelsPath, model, gpuId, saveImageAs));
|
||||||
let failed = false;
|
let failed = false;
|
||||||
const onData = (data) => {
|
const onData = (data) => {
|
||||||
electron_log_1.default.log("🚀 => upscayl.stderr.on => stderr.toString()", data.toString());
|
electron_log_1.default.log("🚀 => upscayl.stderr.on => stderr.toString()", data.toString());
|
||||||
|
@ -2,14 +2,13 @@ import React from "react";
|
|||||||
|
|
||||||
function Footer() {
|
function Footer() {
|
||||||
return (
|
return (
|
||||||
<div className="p-2 text-center text-sm text-neutral-500">
|
<div className="p-2 text-center text-xs text-base-content/50">
|
||||||
<p>
|
<p>
|
||||||
Copyright © 2022 -{" "}
|
Copyright © 2022 -{" "}
|
||||||
<a
|
<a
|
||||||
className="font-bold"
|
className="font-bold"
|
||||||
href="https://github.com/upscayl/upscayl"
|
href="https://github.com/upscayl/upscayl"
|
||||||
target="_blank"
|
target="_blank">
|
||||||
>
|
|
||||||
Upscayl
|
Upscayl
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
@ -18,16 +17,14 @@ function Footer() {
|
|||||||
<a
|
<a
|
||||||
href="https://github.com/TGS963"
|
href="https://github.com/TGS963"
|
||||||
className="font-bold"
|
className="font-bold"
|
||||||
target="_blank"
|
target="_blank">
|
||||||
>
|
|
||||||
TGS963
|
TGS963
|
||||||
</a>{" "}
|
</a>{" "}
|
||||||
and{" "}
|
and{" "}
|
||||||
<a
|
<a
|
||||||
href="https://github.com/NayamAmarshe"
|
href="https://github.com/NayamAmarshe"
|
||||||
className="font-bold"
|
className="font-bold"
|
||||||
target="_blank"
|
target="_blank">
|
||||||
>
|
|
||||||
Nayam Amarshe
|
Nayam Amarshe
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
@ -241,6 +241,21 @@ function LeftPaneImageSteps({
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
<p className="mb-2 text-sm">Set Scale</p>
|
||||||
|
<input
|
||||||
|
type="range"
|
||||||
|
min="2"
|
||||||
|
max="4"
|
||||||
|
value="4"
|
||||||
|
step="1"
|
||||||
|
className="range range-primary mt-2"
|
||||||
|
/>
|
||||||
|
<div className="flex w-full justify-between px-2 text-xs">
|
||||||
|
<span>|</span>
|
||||||
|
<span>|</span>
|
||||||
|
<span>|</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* STEP 3 */}
|
{/* STEP 3 */}
|
||||||
|
@ -159,12 +159,22 @@ const Home = () => {
|
|||||||
// CUSTOM FOLDER LISTENER
|
// CUSTOM FOLDER LISTENER
|
||||||
window.electron.on(
|
window.electron.on(
|
||||||
commands.CUSTOM_MODEL_FILES_LIST,
|
commands.CUSTOM_MODEL_FILES_LIST,
|
||||||
(_, modelsList: string[]) => {
|
(_, data: string[]) => {
|
||||||
console.log("🚀 => file: index.tsx:161 => modelsList:", modelsList);
|
const newModelOptions = data.map((model) => {
|
||||||
|
return {
|
||||||
modelsList.forEach((model: string) => {
|
value: model,
|
||||||
setModelOptions((prev) => [...prev, { label: model, value: model }]);
|
label: model,
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Add newModelsList to modelOptions and remove duplicates
|
||||||
|
const combinedModelOptions = [...modelOptions, ...newModelOptions];
|
||||||
|
const uniqueModelOptions = combinedModelOptions.filter(
|
||||||
|
// Check if any model in the array appears more than once
|
||||||
|
(model, index, array) =>
|
||||||
|
array.findIndex((t) => t.value === model.value) === index
|
||||||
|
);
|
||||||
|
setModelOptions(uniqueModelOptions);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}, []);
|
}, []);
|
||||||
|
Loading…
Reference in New Issue
Block a user