mirror of
https://github.com/upscayl/upscayl.git
synced 2025-01-18 17:14:08 +01:00
Fix batch upscayl format bug and custom models path bug
This commit is contained in:
parent
7f0d56bb14
commit
d6842930a6
13
common/models-list.ts
Normal file
13
common/models-list.ts
Normal 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);
|
@ -15,14 +15,14 @@ import { spawnUpscayl } from "../utils/spawn-upscayl";
|
||||
import { getBatchArguments } from "../utils/get-arguments";
|
||||
import slash from "../utils/slash";
|
||||
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 DEFAULT_MODELS from "../constants/models";
|
||||
import { BatchUpscaylPayload } from "../../common/types/types";
|
||||
import { ImageFormat } from "../utils/types";
|
||||
import getModelScale from "../../common/check-model-scale";
|
||||
import removeFileExtension from "../utils/remove-file-extension";
|
||||
import showNotification from "../utils/show-notification";
|
||||
import { DEFAULT_MODELS } from "../../common/models-list";
|
||||
|
||||
const batchUpscayl = async (event, payload: BatchUpscaylPayload) => {
|
||||
const mainWindow = getMainWindow();
|
||||
@ -67,7 +67,6 @@ const batchUpscayl = async (event, payload: BatchUpscaylPayload) => {
|
||||
|
||||
// UPSCALE
|
||||
const upscayl = spawnUpscayl(
|
||||
"realesrgan",
|
||||
getBatchArguments(
|
||||
inputDir,
|
||||
outputFolderPath,
|
||||
|
@ -5,7 +5,7 @@ import {
|
||||
} from "../utils/config-variables";
|
||||
import logit from "../utils/logit";
|
||||
import slash from "../utils/slash";
|
||||
import COMMAND from "../constants/commands";
|
||||
import COMMAND from "../../common/commands";
|
||||
import getModels from "../utils/get-models";
|
||||
import { getMainWindow } from "../main-window";
|
||||
import settings from "electron-settings";
|
||||
|
@ -11,7 +11,6 @@ import {
|
||||
setStopped,
|
||||
stopped,
|
||||
} from "../utils/config-variables";
|
||||
import DEFAULT_MODELS from "../constants/models";
|
||||
import slash from "../utils/slash";
|
||||
import { spawnUpscayl } from "../utils/spawn-upscayl";
|
||||
import {
|
||||
@ -20,13 +19,14 @@ import {
|
||||
} from "../utils/get-arguments";
|
||||
import { modelsPath } from "../utils/get-resource-paths";
|
||||
import logit from "../utils/logit";
|
||||
import COMMAND from "../constants/commands";
|
||||
import COMMAND from "../../common/commands";
|
||||
import convertAndScale from "../utils/convert-and-scale";
|
||||
import { DoubleUpscaylPayload } from "../../common/types/types";
|
||||
import { ImageFormat } from "../utils/types";
|
||||
import getModelScale from "../../common/check-model-scale";
|
||||
import showNotification from "../utils/show-notification";
|
||||
import { unlinkSync } from "fs";
|
||||
import { DEFAULT_MODELS } from "../../common/models-list";
|
||||
|
||||
const doubleUpscayl = async (event, payload: DoubleUpscaylPayload) => {
|
||||
const mainWindow = getMainWindow();
|
||||
@ -72,7 +72,6 @@ const doubleUpscayl = async (event, payload: DoubleUpscaylPayload) => {
|
||||
|
||||
// UPSCALE
|
||||
let upscayl = spawnUpscayl(
|
||||
"realesrgan",
|
||||
getDoubleUpscaleArguments(
|
||||
inputDir,
|
||||
fullfileName,
|
||||
@ -193,7 +192,6 @@ const doubleUpscayl = async (event, payload: DoubleUpscaylPayload) => {
|
||||
if (!failed && !stopped) {
|
||||
// UPSCALE
|
||||
let upscayl2 = spawnUpscayl(
|
||||
"realesrgan",
|
||||
getDoubleUpscaleSecondPassArguments(
|
||||
isAlpha,
|
||||
outFile,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import COMMAND from "../constants/commands";
|
||||
import COMMAND from "../../common/commands";
|
||||
import { getMainWindow } from "../main-window";
|
||||
import {
|
||||
customModelsFolderPath,
|
||||
|
@ -1,6 +1,6 @@
|
||||
import fs from "fs";
|
||||
import { modelsPath } from "../utils/get-resource-paths";
|
||||
import COMMAND from "../constants/commands";
|
||||
import COMMAND from "../../common/commands";
|
||||
import {
|
||||
compression,
|
||||
customModelsFolderPath,
|
||||
@ -20,13 +20,13 @@ import logit from "../utils/logit";
|
||||
import slash from "../utils/slash";
|
||||
import { spawnUpscayl } from "../utils/spawn-upscayl";
|
||||
import { parse } from "path";
|
||||
import DEFAULT_MODELS from "../constants/models";
|
||||
import { getMainWindow } from "../main-window";
|
||||
import { ImageUpscaylPayload } from "../../common/types/types";
|
||||
import { ImageFormat } from "../utils/types";
|
||||
import getModelScale from "../../common/check-model-scale";
|
||||
import removeFileExtension from "../utils/remove-file-extension";
|
||||
import showNotification from "../utils/show-notification";
|
||||
import { DEFAULT_MODELS } from "../../common/models-list";
|
||||
|
||||
const imageUpscayl = async (event, payload: ImageUpscaylPayload) => {
|
||||
const mainWindow = getMainWindow();
|
||||
@ -55,7 +55,7 @@ const imageUpscayl = async (event, payload: ImageUpscaylPayload) => {
|
||||
}
|
||||
|
||||
const isDefaultModel = DEFAULT_MODELS.includes(model);
|
||||
|
||||
logit("Is Default Model? : ", isDefaultModel);
|
||||
const fullfileName = payload.imagePath.replace(/^.*[\\\/]/, "") as string;
|
||||
const fileName = parse(fullfileName).name;
|
||||
const fileExt = parse(fullfileName).ext;
|
||||
@ -104,7 +104,6 @@ const imageUpscayl = async (event, payload: ImageUpscaylPayload) => {
|
||||
})
|
||||
);
|
||||
const upscayl = spawnUpscayl(
|
||||
"realesrgan",
|
||||
getSingleImageArguments(
|
||||
inputDir,
|
||||
fullfileName,
|
||||
|
@ -1,9 +0,0 @@
|
||||
const DEFAULT_MODELS = [
|
||||
"realesrgan-x4plus",
|
||||
"remacri",
|
||||
"ultramix_balanced",
|
||||
"ultrasharp",
|
||||
"realesrgan-x4plus-anime",
|
||||
];
|
||||
|
||||
export default DEFAULT_MODELS;
|
@ -2,7 +2,7 @@ import prepareNext from "electron-next";
|
||||
import { autoUpdater } from "electron-updater";
|
||||
import log from "electron-log";
|
||||
import { app, ipcMain, protocol } from "electron";
|
||||
import COMMAND from "./constants/commands";
|
||||
import COMMAND from "../common/commands";
|
||||
import logit from "./utils/logit";
|
||||
import openFolder from "./commands/open-folder";
|
||||
import stop from "./commands/stop";
|
||||
@ -42,7 +42,7 @@ app.on("ready", async () => {
|
||||
autoUpdater.checkForUpdates();
|
||||
}
|
||||
|
||||
log.info("🚀 UPSCAYL EXEC PATH: ", execPath("bin"));
|
||||
log.info("🚀 UPSCAYL EXEC PATH: ", execPath);
|
||||
log.info("🚀 MODELS PATH: ", modelsPath);
|
||||
|
||||
let closeAccess;
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { BrowserWindow, shell } from "electron";
|
||||
import { getPlatform } from "./utils/get-device-specs";
|
||||
import { join } from "path";
|
||||
import COMMAND from "./constants/commands";
|
||||
import COMMAND from "../common/commands";
|
||||
import { fetchLocalStorage } from "./utils/config-variables";
|
||||
import electronIsDev from "electron-is-dev";
|
||||
import { format } from "url";
|
||||
|
@ -136,5 +136,5 @@ export const getBatchArguments = (
|
||||
gpuId ? gpuId : "",
|
||||
"-f",
|
||||
saveImageAs,
|
||||
];
|
||||
].filter((arg) => arg !== "");
|
||||
};
|
||||
|
@ -15,7 +15,7 @@ const binariesPath = isDev
|
||||
? join(appRootDir, "resources", getPlatform()!, "bin")
|
||||
: join(dirname(appRootDir), "bin");
|
||||
|
||||
const execPath = (execName) => resolve(join(binariesPath, `./upscayl-bin`));
|
||||
const execPath = resolve(join(binariesPath, `./upscayl-bin`));
|
||||
|
||||
const modelsPath = isDev
|
||||
? resolve(join(appRootDir, "resources", "models"))
|
||||
|
@ -1,5 +1,5 @@
|
||||
import log from "electron-log";
|
||||
import COMMAND from "../constants/commands";
|
||||
import COMMAND from "../../common/commands";
|
||||
import { getMainWindow } from "../main-window";
|
||||
|
||||
const logit = (...args: any) => {
|
||||
|
@ -2,13 +2,12 @@ import { spawn } from "child_process";
|
||||
import { execPath } from "./get-resource-paths";
|
||||
|
||||
export const spawnUpscayl = (
|
||||
binaryName: string,
|
||||
command: string[],
|
||||
logit: (...args: any) => void
|
||||
) => {
|
||||
logit("📢 Upscayl Command: ", command);
|
||||
|
||||
const spawnedProcess = spawn(execPath("bin"), command, {
|
||||
const spawnedProcess = spawn(execPath, command, {
|
||||
cwd: undefined,
|
||||
detached: false,
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "upscayl",
|
||||
"private": true,
|
||||
"version": "2.9.7",
|
||||
"version": "2.9.8",
|
||||
"productName": "Upscayl",
|
||||
"author": {
|
||||
"name": "Nayam Amarshe",
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { defaultModelsList } from "@common/models-list";
|
||||
import { atom } from "jotai";
|
||||
|
||||
export type TModelsList = {
|
||||
@ -5,16 +6,4 @@ export type TModelsList = {
|
||||
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user