1
0
mirror of https://github.com/upscayl/upscayl.git synced 2024-11-12 01:40:53 +01:00

Fix batch upscayl format bug and custom models path bug

This commit is contained in:
Nayam Amarshe 2024-01-16 12:00:07 +05:30
parent 7f0d56bb14
commit d6842930a6
16 changed files with 31 additions and 43 deletions

13
common/models-list.ts Normal file
View File

@ -0,0 +1,13 @@
export const defaultModelsList = [
{ label: "General Photo (Real-ESRGAN)", value: "realesrgan-x4plus" },
{
label: "General Photo (Fast Real-ESRGAN)",
value: "RealESRGAN_General_x4_v3",
},
{ label: "General Photo (Remacri)", value: "remacri" },
{ label: "General Photo (Ultramix Balanced)", value: "ultramix_balanced" },
{ label: "General Photo (Ultrasharp)", value: "ultrasharp" },
{ label: "Digital Art", value: "realesrgan-x4plus-anime" },
];
export const DEFAULT_MODELS = defaultModelsList.map((model) => model.value);

View File

@ -15,14 +15,14 @@ import { spawnUpscayl } from "../utils/spawn-upscayl";
import { getBatchArguments } from "../utils/get-arguments"; import { getBatchArguments } from "../utils/get-arguments";
import slash from "../utils/slash"; import slash from "../utils/slash";
import { modelsPath } from "../utils/get-resource-paths"; import { modelsPath } from "../utils/get-resource-paths";
import COMMAND from "../constants/commands"; import COMMAND from "../../common/commands";
import convertAndScale from "../utils/convert-and-scale"; import convertAndScale from "../utils/convert-and-scale";
import DEFAULT_MODELS from "../constants/models";
import { BatchUpscaylPayload } from "../../common/types/types"; import { BatchUpscaylPayload } from "../../common/types/types";
import { ImageFormat } from "../utils/types"; import { ImageFormat } from "../utils/types";
import getModelScale from "../../common/check-model-scale"; import getModelScale from "../../common/check-model-scale";
import removeFileExtension from "../utils/remove-file-extension"; import removeFileExtension from "../utils/remove-file-extension";
import showNotification from "../utils/show-notification"; import showNotification from "../utils/show-notification";
import { DEFAULT_MODELS } from "../../common/models-list";
const batchUpscayl = async (event, payload: BatchUpscaylPayload) => { const batchUpscayl = async (event, payload: BatchUpscaylPayload) => {
const mainWindow = getMainWindow(); const mainWindow = getMainWindow();
@ -67,7 +67,6 @@ const batchUpscayl = async (event, payload: BatchUpscaylPayload) => {
// UPSCALE // UPSCALE
const upscayl = spawnUpscayl( const upscayl = spawnUpscayl(
"realesrgan",
getBatchArguments( getBatchArguments(
inputDir, inputDir,
outputFolderPath, outputFolderPath,

View File

@ -5,7 +5,7 @@ import {
} from "../utils/config-variables"; } from "../utils/config-variables";
import logit from "../utils/logit"; import logit from "../utils/logit";
import slash from "../utils/slash"; import slash from "../utils/slash";
import COMMAND from "../constants/commands"; import COMMAND from "../../common/commands";
import getModels from "../utils/get-models"; import getModels from "../utils/get-models";
import { getMainWindow } from "../main-window"; import { getMainWindow } from "../main-window";
import settings from "electron-settings"; import settings from "electron-settings";

View File

@ -11,7 +11,6 @@ import {
setStopped, setStopped,
stopped, stopped,
} from "../utils/config-variables"; } from "../utils/config-variables";
import DEFAULT_MODELS from "../constants/models";
import slash from "../utils/slash"; import slash from "../utils/slash";
import { spawnUpscayl } from "../utils/spawn-upscayl"; import { spawnUpscayl } from "../utils/spawn-upscayl";
import { import {
@ -20,13 +19,14 @@ import {
} from "../utils/get-arguments"; } from "../utils/get-arguments";
import { modelsPath } from "../utils/get-resource-paths"; import { modelsPath } from "../utils/get-resource-paths";
import logit from "../utils/logit"; import logit from "../utils/logit";
import COMMAND from "../constants/commands"; import COMMAND from "../../common/commands";
import convertAndScale from "../utils/convert-and-scale"; import convertAndScale from "../utils/convert-and-scale";
import { DoubleUpscaylPayload } from "../../common/types/types"; import { DoubleUpscaylPayload } from "../../common/types/types";
import { ImageFormat } from "../utils/types"; import { ImageFormat } from "../utils/types";
import getModelScale from "../../common/check-model-scale"; import getModelScale from "../../common/check-model-scale";
import showNotification from "../utils/show-notification"; import showNotification from "../utils/show-notification";
import { unlinkSync } from "fs"; import { unlinkSync } from "fs";
import { DEFAULT_MODELS } from "../../common/models-list";
const doubleUpscayl = async (event, payload: DoubleUpscaylPayload) => { const doubleUpscayl = async (event, payload: DoubleUpscaylPayload) => {
const mainWindow = getMainWindow(); const mainWindow = getMainWindow();
@ -72,7 +72,6 @@ const doubleUpscayl = async (event, payload: DoubleUpscaylPayload) => {
// UPSCALE // UPSCALE
let upscayl = spawnUpscayl( let upscayl = spawnUpscayl(
"realesrgan",
getDoubleUpscaleArguments( getDoubleUpscaleArguments(
inputDir, inputDir,
fullfileName, fullfileName,
@ -193,7 +192,6 @@ const doubleUpscayl = async (event, payload: DoubleUpscaylPayload) => {
if (!failed && !stopped) { if (!failed && !stopped) {
// UPSCALE // UPSCALE
let upscayl2 = spawnUpscayl( let upscayl2 = spawnUpscayl(
"realesrgan",
getDoubleUpscaleSecondPassArguments( getDoubleUpscaleSecondPassArguments(
isAlpha, isAlpha,
outFile, outFile,

View File

@ -1,4 +1,4 @@
import COMMAND from "../constants/commands"; import COMMAND from "../../common/commands";
import { getMainWindow } from "../main-window"; import { getMainWindow } from "../main-window";
import { import {
customModelsFolderPath, customModelsFolderPath,

View File

@ -1,6 +1,6 @@
import fs from "fs"; import fs from "fs";
import { modelsPath } from "../utils/get-resource-paths"; import { modelsPath } from "../utils/get-resource-paths";
import COMMAND from "../constants/commands"; import COMMAND from "../../common/commands";
import { import {
compression, compression,
customModelsFolderPath, customModelsFolderPath,
@ -20,13 +20,13 @@ import logit from "../utils/logit";
import slash from "../utils/slash"; import slash from "../utils/slash";
import { spawnUpscayl } from "../utils/spawn-upscayl"; import { spawnUpscayl } from "../utils/spawn-upscayl";
import { parse } from "path"; import { parse } from "path";
import DEFAULT_MODELS from "../constants/models";
import { getMainWindow } from "../main-window"; import { getMainWindow } from "../main-window";
import { ImageUpscaylPayload } from "../../common/types/types"; import { ImageUpscaylPayload } from "../../common/types/types";
import { ImageFormat } from "../utils/types"; import { ImageFormat } from "../utils/types";
import getModelScale from "../../common/check-model-scale"; import getModelScale from "../../common/check-model-scale";
import removeFileExtension from "../utils/remove-file-extension"; import removeFileExtension from "../utils/remove-file-extension";
import showNotification from "../utils/show-notification"; import showNotification from "../utils/show-notification";
import { DEFAULT_MODELS } from "../../common/models-list";
const imageUpscayl = async (event, payload: ImageUpscaylPayload) => { const imageUpscayl = async (event, payload: ImageUpscaylPayload) => {
const mainWindow = getMainWindow(); const mainWindow = getMainWindow();
@ -55,7 +55,7 @@ const imageUpscayl = async (event, payload: ImageUpscaylPayload) => {
} }
const isDefaultModel = DEFAULT_MODELS.includes(model); const isDefaultModel = DEFAULT_MODELS.includes(model);
logit("Is Default Model? : ", isDefaultModel);
const fullfileName = payload.imagePath.replace(/^.*[\\\/]/, "") as string; const fullfileName = payload.imagePath.replace(/^.*[\\\/]/, "") as string;
const fileName = parse(fullfileName).name; const fileName = parse(fullfileName).name;
const fileExt = parse(fullfileName).ext; const fileExt = parse(fullfileName).ext;
@ -104,7 +104,6 @@ const imageUpscayl = async (event, payload: ImageUpscaylPayload) => {
}) })
); );
const upscayl = spawnUpscayl( const upscayl = spawnUpscayl(
"realesrgan",
getSingleImageArguments( getSingleImageArguments(
inputDir, inputDir,
fullfileName, fullfileName,

View File

@ -1,9 +0,0 @@
const DEFAULT_MODELS = [
"realesrgan-x4plus",
"remacri",
"ultramix_balanced",
"ultrasharp",
"realesrgan-x4plus-anime",
];
export default DEFAULT_MODELS;

View File

@ -2,7 +2,7 @@ import prepareNext from "electron-next";
import { autoUpdater } from "electron-updater"; import { autoUpdater } from "electron-updater";
import log from "electron-log"; import log from "electron-log";
import { app, ipcMain, protocol } from "electron"; import { app, ipcMain, protocol } from "electron";
import COMMAND from "./constants/commands"; import COMMAND from "../common/commands";
import logit from "./utils/logit"; import logit from "./utils/logit";
import openFolder from "./commands/open-folder"; import openFolder from "./commands/open-folder";
import stop from "./commands/stop"; import stop from "./commands/stop";
@ -42,7 +42,7 @@ app.on("ready", async () => {
autoUpdater.checkForUpdates(); autoUpdater.checkForUpdates();
} }
log.info("🚀 UPSCAYL EXEC PATH: ", execPath("bin")); log.info("🚀 UPSCAYL EXEC PATH: ", execPath);
log.info("🚀 MODELS PATH: ", modelsPath); log.info("🚀 MODELS PATH: ", modelsPath);
let closeAccess; let closeAccess;

View File

@ -1,7 +1,7 @@
import { BrowserWindow, shell } from "electron"; import { BrowserWindow, shell } from "electron";
import { getPlatform } from "./utils/get-device-specs"; import { getPlatform } from "./utils/get-device-specs";
import { join } from "path"; import { join } from "path";
import COMMAND from "./constants/commands"; import COMMAND from "../common/commands";
import { fetchLocalStorage } from "./utils/config-variables"; import { fetchLocalStorage } from "./utils/config-variables";
import electronIsDev from "electron-is-dev"; import electronIsDev from "electron-is-dev";
import { format } from "url"; import { format } from "url";

View File

@ -136,5 +136,5 @@ export const getBatchArguments = (
gpuId ? gpuId : "", gpuId ? gpuId : "",
"-f", "-f",
saveImageAs, saveImageAs,
]; ].filter((arg) => arg !== "");
}; };

View File

@ -15,7 +15,7 @@ const binariesPath = isDev
? join(appRootDir, "resources", getPlatform()!, "bin") ? join(appRootDir, "resources", getPlatform()!, "bin")
: join(dirname(appRootDir), "bin"); : join(dirname(appRootDir), "bin");
const execPath = (execName) => resolve(join(binariesPath, `./upscayl-bin`)); const execPath = resolve(join(binariesPath, `./upscayl-bin`));
const modelsPath = isDev const modelsPath = isDev
? resolve(join(appRootDir, "resources", "models")) ? resolve(join(appRootDir, "resources", "models"))

View File

@ -1,5 +1,5 @@
import log from "electron-log"; import log from "electron-log";
import COMMAND from "../constants/commands"; import COMMAND from "../../common/commands";
import { getMainWindow } from "../main-window"; import { getMainWindow } from "../main-window";
const logit = (...args: any) => { const logit = (...args: any) => {

View File

@ -2,13 +2,12 @@ import { spawn } from "child_process";
import { execPath } from "./get-resource-paths"; import { execPath } from "./get-resource-paths";
export const spawnUpscayl = ( export const spawnUpscayl = (
binaryName: string,
command: string[], command: string[],
logit: (...args: any) => void logit: (...args: any) => void
) => { ) => {
logit("📢 Upscayl Command: ", command); logit("📢 Upscayl Command: ", command);
const spawnedProcess = spawn(execPath("bin"), command, { const spawnedProcess = spawn(execPath, command, {
cwd: undefined, cwd: undefined,
detached: false, detached: false,
}); });

View File

@ -1,7 +1,7 @@
{ {
"name": "upscayl", "name": "upscayl",
"private": true, "private": true,
"version": "2.9.7", "version": "2.9.8",
"productName": "Upscayl", "productName": "Upscayl",
"author": { "author": {
"name": "Nayam Amarshe", "name": "Nayam Amarshe",

View File

@ -1,3 +1,4 @@
import { defaultModelsList } from "@common/models-list";
import { atom } from "jotai"; import { atom } from "jotai";
export type TModelsList = { export type TModelsList = {
@ -5,16 +6,4 @@ export type TModelsList = {
value: string; value: string;
}[]; }[];
export const defaultModelsList = [
{ label: "General Photo (Real-ESRGAN)", value: "realesrgan-x4plus" },
{
label: "General Photo (Fast Real-ESRGAN)",
value: "RealESRGAN_General_x4_v3",
},
{ label: "General Photo (Remacri)", value: "remacri" },
{ label: "General Photo (Ultramix Balanced)", value: "ultramix_balanced" },
{ label: "General Photo (Ultrasharp)", value: "ultrasharp" },
{ label: "Digital Art", value: "realesrgan-x4plus-anime" },
];
export const modelsListAtom = atom<TModelsList>(defaultModelsList); export const modelsListAtom = atom<TModelsList>(defaultModelsList);