mirror of
https://github.com/upscayl/upscayl.git
synced 2024-11-24 07:30:19 +01:00
implemented working batch mode frontend
This commit is contained in:
parent
313a7db4cb
commit
d2abeb1f13
@ -223,7 +223,6 @@ ipcMain.on(commands.UPSCAYL, async (event, payload) => {
|
|||||||
const scale = payload.scaleFactor;
|
const scale = payload.scaleFactor;
|
||||||
let inputDir = payload.imagePath.match(/(.*)[\/\\]/)[1] || "";
|
let inputDir = payload.imagePath.match(/(.*)[\/\\]/)[1] || "";
|
||||||
let outputDir = payload.outputPath;
|
let outputDir = payload.outputPath;
|
||||||
console.log(outputDir);
|
|
||||||
|
|
||||||
// COPY IMAGE TO TMP FOLDER
|
// COPY IMAGE TO TMP FOLDER
|
||||||
const platform = getPlatform();
|
const platform = getPlatform();
|
||||||
@ -293,10 +292,12 @@ ipcMain.on(commands.UPSCAYL, async (event, payload) => {
|
|||||||
//------------------------Upscayl Folder-----------------------------//
|
//------------------------Upscayl Folder-----------------------------//
|
||||||
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.imagePath;
|
let inputDir = payload.batchFolderPath;
|
||||||
let outputDir = payload.outputPath;
|
let outputDir = payload.outputPath;
|
||||||
console.log(outputDir);
|
console.log(outputDir);
|
||||||
|
if (!fs.existsSync(outputDir)) {
|
||||||
|
fs.mkdirSync(outputDir, { recursive: true });
|
||||||
|
}
|
||||||
// UPSCALE
|
// UPSCALE
|
||||||
let upscayl = spawn(
|
let upscayl = spawn(
|
||||||
execPath("realesrgan"),
|
execPath("realesrgan"),
|
||||||
@ -336,7 +337,7 @@ ipcMain.on(commands.FOLDER_UPSCAYL, async (event, payload) => {
|
|||||||
upscayl.on("close", (code) => {
|
upscayl.on("close", (code) => {
|
||||||
if (failed !== true) {
|
if (failed !== true) {
|
||||||
console.log("Done upscaling");
|
console.log("Done upscaling");
|
||||||
mainWindow.webContents.send(commands.FOLDER_UPSCAYL_DONE, outFile);
|
mainWindow.webContents.send(commands.FOLDER_UPSCAYL_DONE, outputDir);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -21,6 +21,7 @@ const Home = () => {
|
|||||||
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);
|
||||||
|
const [batchFolderPath, setBatchFolderPath] = useState("");
|
||||||
const [doubleUpscayl, setDoubleUpscayl] = useState(false);
|
const [doubleUpscayl, setDoubleUpscayl] = useState(false);
|
||||||
|
|
||||||
const resetImagePaths = () => {
|
const resetImagePaths = () => {
|
||||||
@ -90,6 +91,14 @@ const Home = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const selectFolderHandler = async () => {
|
||||||
|
var path = await window.electron.invoke(commands.SELECT_FOLDER);
|
||||||
|
if (path !== "cancelled") {
|
||||||
|
setBatchFolderPath(path);
|
||||||
|
SetOutputPath(path + "_upscayled");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleModelChange = (e) => {
|
const handleModelChange = (e) => {
|
||||||
setModel(e.target.value);
|
setModel(e.target.value);
|
||||||
};
|
};
|
||||||
@ -164,7 +173,7 @@ const Home = () => {
|
|||||||
|
|
||||||
const upscaylHandler = async () => {
|
const upscaylHandler = async () => {
|
||||||
setUpscaledImagePath("");
|
setUpscaledImagePath("");
|
||||||
if (imagePath !== "") {
|
if (imagePath !== "" || batchFolderPath !== "") {
|
||||||
setProgress("Hold on...");
|
setProgress("Hold on...");
|
||||||
if (model === "models-DF2K") {
|
if (model === "models-DF2K") {
|
||||||
setDoubleUpscayl(false);
|
setDoubleUpscayl(false);
|
||||||
@ -176,6 +185,13 @@ const Home = () => {
|
|||||||
outputPath,
|
outputPath,
|
||||||
model,
|
model,
|
||||||
});
|
});
|
||||||
|
} else if (batchMode) {
|
||||||
|
await window.electron.send(commands.FOLDER_UPSCAYL, {
|
||||||
|
scaleFactor,
|
||||||
|
batchFolderPath,
|
||||||
|
outputPath,
|
||||||
|
model,
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
await window.electron.send(commands.UPSCAYL, {
|
await window.electron.send(commands.UPSCAYL, {
|
||||||
scaleFactor,
|
scaleFactor,
|
||||||
@ -202,6 +218,7 @@ const Home = () => {
|
|||||||
<LeftPaneSteps
|
<LeftPaneSteps
|
||||||
progress={progress}
|
progress={progress}
|
||||||
selectImageHandler={selectImageHandler}
|
selectImageHandler={selectImageHandler}
|
||||||
|
selectFolderHandler={selectFolderHandler}
|
||||||
handleModelChange={handleModelChange}
|
handleModelChange={handleModelChange}
|
||||||
handleDrop={handleDrop}
|
handleDrop={handleDrop}
|
||||||
outputHandler={outputHandler}
|
outputHandler={outputHandler}
|
||||||
@ -231,7 +248,7 @@ const Home = () => {
|
|||||||
<ProgressBar progress={progress} />
|
<ProgressBar progress={progress} />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{imagePath.length === 0 ? (
|
{imagePath.length === 0 && batchFolderPath.length === 0 ? (
|
||||||
<RightPaneInfo version={version} />
|
<RightPaneInfo version={version} />
|
||||||
) : upscaledImagePath.length === 0 ? (
|
) : upscaledImagePath.length === 0 ? (
|
||||||
<img
|
<img
|
||||||
@ -242,7 +259,7 @@ const Home = () => {
|
|||||||
draggable="false"
|
draggable="false"
|
||||||
alt=""
|
alt=""
|
||||||
/>
|
/>
|
||||||
) : (
|
) : !batchMode ? (
|
||||||
<ReactCompareSlider
|
<ReactCompareSlider
|
||||||
itemOne={
|
itemOne={
|
||||||
<ReactCompareSliderImage
|
<ReactCompareSliderImage
|
||||||
@ -264,7 +281,7 @@ const Home = () => {
|
|||||||
}
|
}
|
||||||
className="h-screen"
|
className="h-screen"
|
||||||
/>
|
/>
|
||||||
)}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user