1
0
mirror of https://github.com/upscayl/upscayl.git synced 2025-01-31 12:13:43 +01:00

Fix batch upscayl scale skip and refactor error detection

This commit is contained in:
Nayam Amarshe 2024-04-24 19:14:51 +05:30
parent d739eae7c7
commit 618b46f553
3 changed files with 9 additions and 5 deletions

View File

@ -23,6 +23,7 @@ import { DoubleUpscaylPayload } from "../../common/types/types";
import { ImageFormat } from "../types/types"; import { ImageFormat } from "../types/types";
import showNotification from "../utils/show-notification"; import showNotification from "../utils/show-notification";
import { DEFAULT_MODELS } from "../../common/models-list"; import { DEFAULT_MODELS } from "../../common/models-list";
import getModelScale from "../../common/check-model-scale";
const doubleUpscayl = async (event, payload: DoubleUpscaylPayload) => { const doubleUpscayl = async (event, payload: DoubleUpscaylPayload) => {
const mainWindow = getMainWindow(); const mainWindow = getMainWindow();
@ -49,7 +50,8 @@ const doubleUpscayl = async (event, payload: DoubleUpscaylPayload) => {
const fullfileName = imagePath.split(slash).slice(-1)[0] as string; const fullfileName = imagePath.split(slash).slice(-1)[0] as string;
const fileName = parse(fullfileName).name; const fileName = parse(fullfileName).name;
const scale = parseInt(payload.scale) * parseInt(payload.scale); const modelScale = getModelScale(model);
const scale = parseInt(payload.scale) ** 2;
const useCustomWidth = payload.useCustomWidth; const useCustomWidth = payload.useCustomWidth;
const customWidth = useCustomWidth ? payload.customWidth : ""; const customWidth = useCustomWidth ? payload.customWidth : "";
@ -112,9 +114,11 @@ const doubleUpscayl = async (event, payload: DoubleUpscaylPayload) => {
// SEND UPSCAYL PROGRESS TO RENDERER // SEND UPSCAYL PROGRESS TO RENDERER
mainWindow.webContents.send(COMMAND.DOUBLE_UPSCAYL_PROGRESS, data); mainWindow.webContents.send(COMMAND.DOUBLE_UPSCAYL_PROGRESS, data);
// IF PROGRESS HAS ERROR, UPSCAYL FAILED // IF PROGRESS HAS ERROR, UPSCAYL FAILED
if (data.includes("invalid gpu") || data.includes("failed")) { if (data.includes("Error")) {
upscayl2.kill(); upscayl2.kill();
failed2 = true; failed2 = true;
} else if (data.includes("Resizing")) {
mainWindow.webContents.send(COMMAND.SCALING_AND_CONVERTING);
} }
}; };
@ -187,6 +191,7 @@ const doubleUpscayl = async (event, payload: DoubleUpscaylPayload) => {
}), }),
logit, logit,
); );
logit("🚀 Upscaling Second Pass");
childProcesses.push(upscayl2); childProcesses.push(upscayl2);
upscayl2.process.stderr.on("data", onData2); upscayl2.process.stderr.on("data", onData2);
upscayl2.process.on("error", onError2); upscayl2.process.on("error", onError2);

View File

@ -118,7 +118,6 @@ const imageUpscayl = async (event, payload: ImageUpscaylPayload) => {
setChildProcesses(upscayl); setChildProcesses(upscayl);
setStopped(false); setStopped(false);
let isAlpha = false;
let failed = false; let failed = false;
const onData = (data: string) => { const onData = (data: string) => {
@ -126,7 +125,7 @@ const imageUpscayl = async (event, payload: ImageUpscaylPayload) => {
mainWindow.setProgressBar(parseFloat(data.slice(0, data.length)) / 100); mainWindow.setProgressBar(parseFloat(data.slice(0, data.length)) / 100);
data = data.toString(); data = data.toString();
mainWindow.webContents.send(COMMAND.UPSCAYL_PROGRESS, data.toString()); mainWindow.webContents.send(COMMAND.UPSCAYL_PROGRESS, data.toString());
if (data.includes("invalid gpu") || data.includes("failed")) { if (data.includes("Error")) {
upscayl.kill(); upscayl.kill();
failed = true; failed = true;
} else if (data.includes("Resizing")) { } else if (data.includes("Resizing")) {

View File

@ -110,7 +110,7 @@ export const getDoubleUpscaleSecondPassArguments = ({
scale: string; scale: string;
customWidth: string; customWidth: string;
}) => { }) => {
const modelScale = getModelScale(model); const modelScale = (parseInt(getModelScale(model)) ** 2).toString();
let includeScale = modelScale !== scale && !customWidth; let includeScale = modelScale !== scale && !customWidth;
return [ return [
// INPUT IMAGE // INPUT IMAGE