mirror of
https://github.com/upscayl/upscayl.git
synced 2025-01-31 04:03:51 +01:00
Fixed path bugs and errors
This commit is contained in:
parent
e88100e802
commit
f9308b5c9d
Binary file not shown.
Before Width: | Height: | Size: 20 KiB |
@ -1,16 +1,21 @@
|
||||
const { join, dirname } = require("path");
|
||||
const path = require("path");
|
||||
/*
|
||||
appRootDir is the resources directory inside the unpacked electron app temp directory.
|
||||
resources contains app.asar file, that contains the main and renderer files.
|
||||
We're putting resources/{os}/bin from project inside resources/bin of electron. Same for the models directory as well.
|
||||
*/
|
||||
|
||||
const { join, dirname, resolve } = require("path");
|
||||
const { getPlatform } = require("./getPlatform");
|
||||
const appRootDir = require("app-root-dir");
|
||||
const isDev = require("electron-is-dev");
|
||||
|
||||
const binariesPath = isDev
|
||||
? join(appRootDir.get(), "resources", getPlatform(), "bin")
|
||||
: join(dirname(appRootDir.get()), "..", "Resources", "bin");
|
||||
: join(dirname(appRootDir.get()), "bin");
|
||||
|
||||
const execPath = path.resolve(path.join(binariesPath, "./upscayl"));
|
||||
const modelsPath = isDev
|
||||
? path.resolve(path.join(binariesPath, "../../models"))
|
||||
: path.resolve(path.join(binariesPath, "../models"))
|
||||
const execPath = resolve(join(binariesPath, "./upscayl"));
|
||||
const modelsPath = isDev
|
||||
? resolve(join(appRootDir.get(), "resources", "models"))
|
||||
: resolve(join(dirname(appRootDir.get()), "models"));
|
||||
|
||||
module.exports = { execPath, modelsPath };
|
||||
|
@ -27,7 +27,11 @@ let mainWindow;
|
||||
app.on("ready", async () => {
|
||||
await prepareNext("./renderer");
|
||||
|
||||
console.log("ICON: ", join(__dirname, "icon.png"));
|
||||
console.log("🚀 Icon Path: ", join(__dirname, "icon.png"));
|
||||
console.log("🚀 Development Mode? :", isDev);
|
||||
console.log("🚀 RS Executable Path: ", execPath);
|
||||
console.log("🚀 Models: ", modelsPath);
|
||||
|
||||
mainWindow = new BrowserWindow({
|
||||
icon: join(__dirname, "build", "icon.png"),
|
||||
width: 1100,
|
||||
@ -53,7 +57,6 @@ app.on("ready", async () => {
|
||||
});
|
||||
|
||||
mainWindow.setMenuBarVisibility(false);
|
||||
// mainWindow.maximize();
|
||||
mainWindow.loadURL(url);
|
||||
|
||||
mainWindow.webContents.setWindowOpenHandler(({ url }) => {
|
||||
@ -74,7 +77,6 @@ app.on("ready", async () => {
|
||||
app.on("window-all-closed", app.quit);
|
||||
|
||||
// ! DONT FORGET TO RESTART THE APP WHEN YOU CHANGE CODE HERE
|
||||
|
||||
ipcMain.handle(commands.SELECT_FILE, async () => {
|
||||
const { canceled, filePaths } = await dialog.showOpenDialog({
|
||||
properties: ["openFile", "multiSelections"],
|
||||
@ -109,7 +111,7 @@ ipcMain.on(commands.UPSCAYL, async (event, payload) => {
|
||||
|
||||
let inputDir = payload.imagePath.match(/(.*)[\/\\]/)[1] || "";
|
||||
let outputDir = payload.outputPath;
|
||||
console.log("🚀 => ipcMain.on => outputDir", outputDir);
|
||||
console.log("🚀 => ipcMain => outputDir", outputDir);
|
||||
|
||||
// COPY IMAGE TO TMP FOLDER
|
||||
const platform = getPlatform();
|
||||
@ -123,10 +125,8 @@ ipcMain.on(commands.UPSCAYL, async (event, payload) => {
|
||||
outputDir + "/" + fileName + "_upscayled_" + scale + "x_" + model + fileExt;
|
||||
|
||||
// UPSCALE
|
||||
console.log("PRODUCTION? :", isDev);
|
||||
console.log("EXEC: ", execPath);
|
||||
console.log("MODEL: ", modelsPath + "/" + model);
|
||||
if (fs.existsSync(outFile)) {
|
||||
// If already upscayled, just output that file
|
||||
mainWindow.webContents.send(commands.UPSCAYL_DONE, outFile);
|
||||
} else {
|
||||
let upscayl = model.includes("realesrgan")
|
||||
@ -169,16 +169,17 @@ ipcMain.on(commands.UPSCAYL, async (event, payload) => {
|
||||
);
|
||||
|
||||
let failed = false;
|
||||
|
||||
upscayl.stderr.on("data", (stderr) => {
|
||||
console.log(stderr.toString());
|
||||
stderr = stderr.toString();
|
||||
if (stderr.includes("invalid gpu")) {
|
||||
failed = true;
|
||||
}
|
||||
mainWindow.webContents.send(commands.UPSCAYL_PROGRESS, stderr.toString());
|
||||
if (stderr.includes("invalid gpu") || stderr.includes("failed")) {
|
||||
failed = true;
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
// Send done comamnd when
|
||||
upscayl.on("close", (code) => {
|
||||
if (failed !== true) {
|
||||
console.log("Done upscaling");
|
||||
|
@ -53,14 +53,14 @@
|
||||
"extraFiles": [
|
||||
{
|
||||
"from": "resources/${os}/bin",
|
||||
"to": "Resources/bin",
|
||||
"to": "resources/bin",
|
||||
"filter": [
|
||||
"**/*"
|
||||
]
|
||||
},
|
||||
{
|
||||
"from": "resources/models",
|
||||
"to": "Resources/models",
|
||||
"to": "resources/models",
|
||||
"filter": [
|
||||
"**/*"
|
||||
]
|
||||
@ -69,8 +69,8 @@
|
||||
"mac": {
|
||||
"type": "distribution",
|
||||
"hardenedRuntime": true,
|
||||
"entitlements": "resources/entitlements.mac.plist",
|
||||
"entitlementsInherit": "resources/entitlements.mac.plist",
|
||||
"entitlements": "main/resources/entitlements.mac.plist",
|
||||
"entitlementsInherit": "main/resources/entitlements.mac.plist",
|
||||
"gatekeeperAssess": false,
|
||||
"target": [
|
||||
{
|
||||
|
@ -2,7 +2,7 @@ import React from "react";
|
||||
|
||||
function LeftPaneSteps(props) {
|
||||
return (
|
||||
<div className="animate-step-in flex h-screen flex-col gap-10 overflow-auto p-5">
|
||||
<div className="animate-step-in animate flex h-screen flex-col gap-10 overflow-auto p-5">
|
||||
{/* STEP 1 */}
|
||||
<div className="">
|
||||
<p className="mb-2 font-medium text-neutral-100">Step 1</p>
|
||||
@ -26,7 +26,7 @@ function LeftPaneSteps(props) {
|
||||
>
|
||||
<option value="realesrgan-x4plus">General Photo</option>
|
||||
<option value="realesrgan-x4plus-anime">Digital Art</option>
|
||||
<option value="models-DF2K">Sharpen Image</option>
|
||||
<option value="models-DF2K">Sharpen</option>
|
||||
<option value="models-DF2K_JPEG">Sharpen JPEG</option>
|
||||
</select>
|
||||
</div>
|
||||
|
@ -3,7 +3,7 @@ import React from "react";
|
||||
function ResetButton(props) {
|
||||
return (
|
||||
<button
|
||||
className="absolute bottom-1 right-1 z-10 rounded-full bg-sky-400 py-2 px-4 opacity-50"
|
||||
className="animate absolute bottom-1 right-1 z-10 rounded-full bg-sky-400 py-2 px-4 opacity-50 hover:opacity-100"
|
||||
onClick={props.resetImagePaths}
|
||||
>
|
||||
Reset
|
||||
|
@ -27,12 +27,9 @@ const Home = () => {
|
||||
setUpscaledImagePath("");
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
setVersion(navigator.userAgent.match(/Upscayl\/([\d\.]+\d+)/)[1]);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
setLoaded(true);
|
||||
setVersion(navigator.userAgent.match(/Upscayl\/([\d\.]+\d+)/)[1]);
|
||||
|
||||
window.electron.on(commands.UPSCAYL_PROGRESS, (_, data) => {
|
||||
if (data.includes("invalid gpu")) {
|
||||
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Before Width: | Height: | Size: 1.6 MiB |
Binary file not shown.
Before Width: | Height: | Size: 1.6 MiB |
BIN
to_upscale_upscayled_4x_realesrgan-x4plus.jpeg
Normal file
BIN
to_upscale_upscayled_4x_realesrgan-x4plus.jpeg
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 MiB |
Binary file not shown.
After Width: | Height: | Size: 15 MiB |
Binary file not shown.
Before Width: | Height: | Size: 2.5 MiB |
Loading…
x
Reference in New Issue
Block a user