mirror of
https://github.com/upscayl/upscayl.git
synced 2024-11-27 17:00:52 +01:00
Add tilesize and add compression in arguments
This commit is contained in:
parent
5feabea516
commit
3f76011ba5
3
common/types/types.d.ts
vendored
3
common/types/types.d.ts
vendored
@ -12,6 +12,7 @@ export type ImageUpscaylPayload = {
|
|||||||
noImageProcessing: boolean;
|
noImageProcessing: boolean;
|
||||||
customWidth: string;
|
customWidth: string;
|
||||||
useCustomWidth: boolean;
|
useCustomWidth: boolean;
|
||||||
|
tileSize: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type DoubleUpscaylPayload = {
|
export type DoubleUpscaylPayload = {
|
||||||
@ -28,6 +29,7 @@ export type DoubleUpscaylPayload = {
|
|||||||
noImageProcessing: boolean;
|
noImageProcessing: boolean;
|
||||||
customWidth: string;
|
customWidth: string;
|
||||||
useCustomWidth: boolean;
|
useCustomWidth: boolean;
|
||||||
|
tileSize: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type BatchUpscaylPayload = {
|
export type BatchUpscaylPayload = {
|
||||||
@ -41,4 +43,5 @@ export type BatchUpscaylPayload = {
|
|||||||
noImageProcessing: boolean;
|
noImageProcessing: boolean;
|
||||||
customWidth: string;
|
customWidth: string;
|
||||||
useCustomWidth: boolean;
|
useCustomWidth: boolean;
|
||||||
|
tileSize: number;
|
||||||
};
|
};
|
||||||
|
@ -20,6 +20,8 @@ const batchUpscayl = async (event, payload: BatchUpscaylPayload) => {
|
|||||||
const mainWindow = getMainWindow();
|
const mainWindow = getMainWindow();
|
||||||
if (!mainWindow) return;
|
if (!mainWindow) return;
|
||||||
|
|
||||||
|
const tileSize = payload.tileSize;
|
||||||
|
const compression = payload.compression;
|
||||||
const scale = payload.scale;
|
const scale = payload.scale;
|
||||||
const useCustomWidth = payload.useCustomWidth;
|
const useCustomWidth = payload.useCustomWidth;
|
||||||
const customWidth = useCustomWidth ? payload.customWidth : "";
|
const customWidth = useCustomWidth ? payload.customWidth : "";
|
||||||
@ -54,6 +56,8 @@ const batchUpscayl = async (event, payload: BatchUpscaylPayload) => {
|
|||||||
saveImageAs,
|
saveImageAs,
|
||||||
scale,
|
scale,
|
||||||
customWidth,
|
customWidth,
|
||||||
|
compression,
|
||||||
|
tileSize,
|
||||||
}),
|
}),
|
||||||
logit,
|
logit,
|
||||||
);
|
);
|
||||||
|
@ -27,6 +27,7 @@ const doubleUpscayl = async (event, payload: DoubleUpscaylPayload) => {
|
|||||||
const mainWindow = getMainWindow();
|
const mainWindow = getMainWindow();
|
||||||
if (!mainWindow) return;
|
if (!mainWindow) return;
|
||||||
|
|
||||||
|
const tileSize = payload.tileSize;
|
||||||
const compression = payload.compression;
|
const compression = payload.compression;
|
||||||
const scale = parseInt(payload.scale) ** 2;
|
const scale = parseInt(payload.scale) ** 2;
|
||||||
const useCustomWidth = payload.useCustomWidth;
|
const useCustomWidth = payload.useCustomWidth;
|
||||||
@ -66,6 +67,7 @@ const doubleUpscayl = async (event, payload: DoubleUpscaylPayload) => {
|
|||||||
model,
|
model,
|
||||||
gpuId,
|
gpuId,
|
||||||
saveImageAs,
|
saveImageAs,
|
||||||
|
tileSize,
|
||||||
}),
|
}),
|
||||||
logit,
|
logit,
|
||||||
);
|
);
|
||||||
@ -172,6 +174,7 @@ const doubleUpscayl = async (event, payload: DoubleUpscaylPayload) => {
|
|||||||
scale: scale.toString(),
|
scale: scale.toString(),
|
||||||
customWidth,
|
customWidth,
|
||||||
compression,
|
compression,
|
||||||
|
tileSize,
|
||||||
}),
|
}),
|
||||||
logit,
|
logit,
|
||||||
);
|
);
|
||||||
|
@ -30,6 +30,7 @@ const imageUpscayl = async (event, payload: ImageUpscaylPayload) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GET VARIABLES
|
// GET VARIABLES
|
||||||
|
const tileSize = payload.tileSize;
|
||||||
const compression = payload.compression;
|
const compression = payload.compression;
|
||||||
const scale = payload.scale;
|
const scale = payload.scale;
|
||||||
const useCustomWidth = payload.useCustomWidth;
|
const useCustomWidth = payload.useCustomWidth;
|
||||||
@ -75,6 +76,9 @@ const imageUpscayl = async (event, payload: ImageUpscaylPayload) => {
|
|||||||
fileName,
|
fileName,
|
||||||
scale,
|
scale,
|
||||||
compression,
|
compression,
|
||||||
|
customWidth,
|
||||||
|
useCustomWidth,
|
||||||
|
tileSize,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
const upscayl = spawnUpscayl(
|
const upscayl = spawnUpscayl(
|
||||||
@ -90,6 +94,8 @@ const imageUpscayl = async (event, payload: ImageUpscaylPayload) => {
|
|||||||
gpuId,
|
gpuId,
|
||||||
saveImageAs,
|
saveImageAs,
|
||||||
customWidth,
|
customWidth,
|
||||||
|
compression,
|
||||||
|
tileSize,
|
||||||
}),
|
}),
|
||||||
logit,
|
logit,
|
||||||
);
|
);
|
||||||
|
@ -13,6 +13,8 @@ export const getSingleImageArguments = ({
|
|||||||
gpuId,
|
gpuId,
|
||||||
saveImageAs,
|
saveImageAs,
|
||||||
customWidth,
|
customWidth,
|
||||||
|
tileSize,
|
||||||
|
compression,
|
||||||
}: {
|
}: {
|
||||||
inputDir: string;
|
inputDir: string;
|
||||||
fileNameWithExt: string;
|
fileNameWithExt: string;
|
||||||
@ -23,6 +25,8 @@ export const getSingleImageArguments = ({
|
|||||||
gpuId: string;
|
gpuId: string;
|
||||||
saveImageAs: ImageFormat;
|
saveImageAs: ImageFormat;
|
||||||
customWidth: string;
|
customWidth: string;
|
||||||
|
tileSize: number;
|
||||||
|
compression: string;
|
||||||
}) => {
|
}) => {
|
||||||
const modelScale = getModelScale(model);
|
const modelScale = getModelScale(model);
|
||||||
let includeScale = modelScale !== scale && !customWidth;
|
let includeScale = modelScale !== scale && !customWidth;
|
||||||
@ -51,6 +55,12 @@ export const getSingleImageArguments = ({
|
|||||||
// CUSTOM WIDTH
|
// CUSTOM WIDTH
|
||||||
customWidth ? `-w` : "",
|
customWidth ? `-w` : "",
|
||||||
customWidth ? customWidth : "",
|
customWidth ? customWidth : "",
|
||||||
|
// COMPRESSION
|
||||||
|
"-c",
|
||||||
|
compression,
|
||||||
|
// TILE SIZE
|
||||||
|
tileSize ? `-t` : "",
|
||||||
|
tileSize ? tileSize.toString() : "",
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -62,6 +72,7 @@ export const getDoubleUpscaleArguments = ({
|
|||||||
model,
|
model,
|
||||||
gpuId,
|
gpuId,
|
||||||
saveImageAs,
|
saveImageAs,
|
||||||
|
tileSize,
|
||||||
}: {
|
}: {
|
||||||
inputDir: string;
|
inputDir: string;
|
||||||
fullfileName: string;
|
fullfileName: string;
|
||||||
@ -70,6 +81,7 @@ export const getDoubleUpscaleArguments = ({
|
|||||||
model: string;
|
model: string;
|
||||||
gpuId: string;
|
gpuId: string;
|
||||||
saveImageAs: ImageFormat;
|
saveImageAs: ImageFormat;
|
||||||
|
tileSize: number;
|
||||||
}) => {
|
}) => {
|
||||||
return [
|
return [
|
||||||
// INPUT IMAGE
|
// INPUT IMAGE
|
||||||
@ -90,6 +102,9 @@ export const getDoubleUpscaleArguments = ({
|
|||||||
// FORMAT
|
// FORMAT
|
||||||
"-f",
|
"-f",
|
||||||
saveImageAs,
|
saveImageAs,
|
||||||
|
// TILE SIZE
|
||||||
|
tileSize ? `-t` : "",
|
||||||
|
tileSize ? tileSize.toString() : "",
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -101,6 +116,8 @@ export const getDoubleUpscaleSecondPassArguments = ({
|
|||||||
saveImageAs,
|
saveImageAs,
|
||||||
scale,
|
scale,
|
||||||
customWidth,
|
customWidth,
|
||||||
|
compression,
|
||||||
|
tileSize,
|
||||||
}: {
|
}: {
|
||||||
outFile: string;
|
outFile: string;
|
||||||
modelsPath: string;
|
modelsPath: string;
|
||||||
@ -110,6 +127,7 @@ export const getDoubleUpscaleSecondPassArguments = ({
|
|||||||
scale: string;
|
scale: string;
|
||||||
customWidth: string;
|
customWidth: string;
|
||||||
compression: string;
|
compression: string;
|
||||||
|
tileSize: number;
|
||||||
}) => {
|
}) => {
|
||||||
const modelScale = (parseInt(getModelScale(model)) ** 2).toString();
|
const modelScale = (parseInt(getModelScale(model)) ** 2).toString();
|
||||||
let includeScale = modelScale !== scale && !customWidth;
|
let includeScale = modelScale !== scale && !customWidth;
|
||||||
@ -138,6 +156,12 @@ export const getDoubleUpscaleSecondPassArguments = ({
|
|||||||
// CUSTOM WIDTH
|
// CUSTOM WIDTH
|
||||||
customWidth ? `-w` : "",
|
customWidth ? `-w` : "",
|
||||||
customWidth ? customWidth : "",
|
customWidth ? customWidth : "",
|
||||||
|
// COMPRESSION
|
||||||
|
"-c",
|
||||||
|
compression,
|
||||||
|
// TILE SIZE
|
||||||
|
tileSize ? `-t` : "",
|
||||||
|
tileSize ? tileSize.toString() : "",
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -150,6 +174,8 @@ export const getBatchArguments = ({
|
|||||||
saveImageAs,
|
saveImageAs,
|
||||||
scale,
|
scale,
|
||||||
customWidth,
|
customWidth,
|
||||||
|
compression,
|
||||||
|
tileSize,
|
||||||
}: {
|
}: {
|
||||||
inputDir: string;
|
inputDir: string;
|
||||||
outputDir: string;
|
outputDir: string;
|
||||||
@ -159,6 +185,8 @@ export const getBatchArguments = ({
|
|||||||
saveImageAs: ImageFormat;
|
saveImageAs: ImageFormat;
|
||||||
scale: string;
|
scale: string;
|
||||||
customWidth: string;
|
customWidth: string;
|
||||||
|
compression: string;
|
||||||
|
tileSize: number;
|
||||||
}) => {
|
}) => {
|
||||||
const modelScale = getModelScale(model);
|
const modelScale = getModelScale(model);
|
||||||
let includeScale = modelScale !== scale && !customWidth;
|
let includeScale = modelScale !== scale && !customWidth;
|
||||||
@ -188,5 +216,11 @@ export const getBatchArguments = ({
|
|||||||
// CUSTOM WIDTH
|
// CUSTOM WIDTH
|
||||||
customWidth ? `-w` : "",
|
customWidth ? `-w` : "",
|
||||||
customWidth ? customWidth : "",
|
customWidth ? customWidth : "",
|
||||||
|
// COMPRESSION
|
||||||
|
"-c",
|
||||||
|
compression,
|
||||||
|
// TILE SIZE
|
||||||
|
tileSize ? `-t` : "",
|
||||||
|
tileSize ? tileSize.toString() : "",
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
@ -59,5 +59,7 @@ export const useCustomWidthAtom = atomWithStorage<boolean>(
|
|||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const tileSizeAtom = atomWithStorage<number | null>("tileSize", null);
|
||||||
|
|
||||||
// CLIENT SIDE ONLY
|
// CLIENT SIDE ONLY
|
||||||
export const showSidebarAtom = atomWithStorage("showSidebar", true);
|
export const showSidebarAtom = atomWithStorage("showSidebar", true);
|
||||||
|
36
renderer/components/settings-tab/TileSizeInput.tsx
Normal file
36
renderer/components/settings-tab/TileSizeInput.tsx
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import { tileSizeAtom } from "@/atoms/userSettingsAtom";
|
||||||
|
import { useAtom } from "jotai";
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
|
export function TileSizeInput() {
|
||||||
|
const [tileSize, setTileSize] = useAtom(tileSizeAtom);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div className="flex flex-col gap-1">
|
||||||
|
<p className="text-sm font-medium">CUSTOM TILE SIZE</p>
|
||||||
|
<p className="text-xs text-base-content/80">
|
||||||
|
<br />
|
||||||
|
Use a custom tile size for segmenting the image. This can help process
|
||||||
|
images faster by reducing the number of tiles generated.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div className="mt-2 flex items-center gap-2">
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
value={tileSize}
|
||||||
|
onChange={(e) => {
|
||||||
|
if (e.currentTarget.value === "") {
|
||||||
|
setTileSize(null);
|
||||||
|
localStorage.removeItem("customWidth");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setTileSize(parseInt(e.currentTarget.value));
|
||||||
|
}}
|
||||||
|
placeholder="0 = Auto"
|
||||||
|
className="input input-primary [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
@ -20,6 +20,7 @@ import { featureFlags } from "@common/feature-flags";
|
|||||||
import TurnOffNotificationsToggle from "./TurnOffNotificationsToggle";
|
import TurnOffNotificationsToggle from "./TurnOffNotificationsToggle";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { CustomResolutionInput } from "./CustomResolutionInput";
|
import { CustomResolutionInput } from "./CustomResolutionInput";
|
||||||
|
import { TileSizeInput } from "./TileSizeInput";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
batchMode: boolean;
|
batchMode: boolean;
|
||||||
@ -236,6 +237,8 @@ function SettingsTab({
|
|||||||
{/* GPU ID INPUT */}
|
{/* GPU ID INPUT */}
|
||||||
<GpuIdInput gpuId={gpuId} handleGpuIdChange={handleGpuIdChange} />
|
<GpuIdInput gpuId={gpuId} handleGpuIdChange={handleGpuIdChange} />
|
||||||
|
|
||||||
|
<TileSizeInput />
|
||||||
|
|
||||||
{/* CUSTOM MODEL */}
|
{/* CUSTOM MODEL */}
|
||||||
<CustomModelsFolderSelect
|
<CustomModelsFolderSelect
|
||||||
customModelsPath={customModelsPath}
|
customModelsPath={customModelsPath}
|
||||||
|
@ -28,6 +28,7 @@ import {
|
|||||||
showSidebarAtom,
|
showSidebarAtom,
|
||||||
customWidthAtom,
|
customWidthAtom,
|
||||||
useCustomWidthAtom,
|
useCustomWidthAtom,
|
||||||
|
tileSizeAtom,
|
||||||
} from "../atoms/userSettingsAtom";
|
} from "../atoms/userSettingsAtom";
|
||||||
import useLog from "../components/hooks/useLog";
|
import useLog from "../components/hooks/useLog";
|
||||||
import { UpscaylCloudModal } from "../components/UpscaylCloudModal";
|
import { UpscaylCloudModal } from "../components/UpscaylCloudModal";
|
||||||
@ -96,6 +97,7 @@ const Home = () => {
|
|||||||
const [showSidebar, setShowSidebar] = useAtom(showSidebarAtom);
|
const [showSidebar, setShowSidebar] = useAtom(showSidebarAtom);
|
||||||
const customWidth = useAtomValue(customWidthAtom);
|
const customWidth = useAtomValue(customWidthAtom);
|
||||||
const useCustomWidth = useAtomValue(useCustomWidthAtom);
|
const useCustomWidth = useAtomValue(useCustomWidthAtom);
|
||||||
|
const tileSize = useAtomValue(tileSizeAtom);
|
||||||
|
|
||||||
const { logit } = useLog();
|
const { logit } = useLog();
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
@ -540,6 +542,7 @@ const Home = () => {
|
|||||||
compression: compression.toString(),
|
compression: compression.toString(),
|
||||||
customWidth: customWidth > 0 ? customWidth.toString() : null,
|
customWidth: customWidth > 0 ? customWidth.toString() : null,
|
||||||
useCustomWidth,
|
useCustomWidth,
|
||||||
|
tileSize,
|
||||||
});
|
});
|
||||||
logit("🏁 DOUBLE_UPSCAYL");
|
logit("🏁 DOUBLE_UPSCAYL");
|
||||||
} else if (batchMode) {
|
} else if (batchMode) {
|
||||||
@ -556,6 +559,7 @@ const Home = () => {
|
|||||||
compression: compression.toString(),
|
compression: compression.toString(),
|
||||||
customWidth: customWidth > 0 ? customWidth.toString() : null,
|
customWidth: customWidth > 0 ? customWidth.toString() : null,
|
||||||
useCustomWidth,
|
useCustomWidth,
|
||||||
|
tileSize,
|
||||||
});
|
});
|
||||||
logit("🏁 FOLDER_UPSCAYL");
|
logit("🏁 FOLDER_UPSCAYL");
|
||||||
} else {
|
} else {
|
||||||
@ -572,6 +576,7 @@ const Home = () => {
|
|||||||
compression: compression.toString(),
|
compression: compression.toString(),
|
||||||
customWidth: customWidth > 0 ? customWidth.toString() : null,
|
customWidth: customWidth > 0 ? customWidth.toString() : null,
|
||||||
useCustomWidth,
|
useCustomWidth,
|
||||||
|
tileSize,
|
||||||
});
|
});
|
||||||
logit("🏁 UPSCAYL");
|
logit("🏁 UPSCAYL");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user