mirror of
https://github.com/upscayl/upscayl.git
synced 2024-11-23 23:21:05 +01:00
Added custom model check
This commit is contained in:
parent
33f85d96d4
commit
abd7063cb3
@ -94,6 +94,15 @@ let imagePath: string | undefined = undefined;
|
|||||||
let folderPath: string | undefined = undefined;
|
let folderPath: string | undefined = undefined;
|
||||||
let customModelsFolderPath: string | undefined = undefined;
|
let customModelsFolderPath: string | undefined = undefined;
|
||||||
|
|
||||||
|
// Default models
|
||||||
|
const defaultModels = [
|
||||||
|
"realesrgan-x4plus",
|
||||||
|
"remacri",
|
||||||
|
"ultramix_balanced",
|
||||||
|
"ultrasharp",
|
||||||
|
"realesrgan-x4plus-anime",
|
||||||
|
];
|
||||||
|
|
||||||
//------------------------Select File-----------------------------//
|
//------------------------Select File-----------------------------//
|
||||||
// ! DONT FORGET TO RESTART THE APP WHEN YOU CHANGE CODE HERE
|
// ! DONT FORGET TO RESTART THE APP WHEN YOU CHANGE CODE HERE
|
||||||
ipcMain.handle(commands.SELECT_FILE, async () => {
|
ipcMain.handle(commands.SELECT_FILE, async () => {
|
||||||
@ -198,6 +207,7 @@ const getModels = (folderPath: string) => {
|
|||||||
|
|
||||||
ipcMain.on(commands.GET_MODELS_LIST, async (event, payload) => {
|
ipcMain.on(commands.GET_MODELS_LIST, async (event, payload) => {
|
||||||
if (payload) {
|
if (payload) {
|
||||||
|
customModelsFolderPath = payload;
|
||||||
mainWindow.webContents.send(
|
mainWindow.webContents.send(
|
||||||
commands.CUSTOM_MODEL_FILES_LIST,
|
commands.CUSTOM_MODEL_FILES_LIST,
|
||||||
getModels(payload)
|
getModels(payload)
|
||||||
@ -241,6 +251,8 @@ ipcMain.on(commands.DOUBLE_UPSCAYL, async (event, payload) => {
|
|||||||
const gpuId = payload.gpuId as string;
|
const gpuId = payload.gpuId as string;
|
||||||
const saveImageAs = payload.saveImageAs as string;
|
const saveImageAs = payload.saveImageAs as string;
|
||||||
|
|
||||||
|
const isDefaultModel = defaultModels.includes(model);
|
||||||
|
|
||||||
// COPY IMAGE TO TMP FOLDER
|
// COPY IMAGE TO TMP FOLDER
|
||||||
const platform = getPlatform();
|
const platform = getPlatform();
|
||||||
const fullfileName =
|
const fullfileName =
|
||||||
@ -259,7 +271,7 @@ ipcMain.on(commands.DOUBLE_UPSCAYL, async (event, payload) => {
|
|||||||
inputDir,
|
inputDir,
|
||||||
fullfileName,
|
fullfileName,
|
||||||
outFile,
|
outFile,
|
||||||
modelsPath,
|
isDefaultModel ? modelsPath : customModelsFolderPath ?? modelsPath,
|
||||||
model,
|
model,
|
||||||
gpuId,
|
gpuId,
|
||||||
saveImageAs
|
saveImageAs
|
||||||
@ -334,7 +346,7 @@ ipcMain.on(commands.DOUBLE_UPSCAYL, async (event, payload) => {
|
|||||||
getDoubleUpscaleSecondPassArguments(
|
getDoubleUpscaleSecondPassArguments(
|
||||||
isAlpha,
|
isAlpha,
|
||||||
outFile,
|
outFile,
|
||||||
modelsPath,
|
isDefaultModel ? modelsPath : customModelsFolderPath ?? modelsPath,
|
||||||
model,
|
model,
|
||||||
gpuId,
|
gpuId,
|
||||||
saveImageAs
|
saveImageAs
|
||||||
@ -357,6 +369,8 @@ ipcMain.on(commands.UPSCAYL, async (event, payload) => {
|
|||||||
let inputDir = (payload.imagePath.match(/(.*)[\/\\]/)[1] || "") as string;
|
let inputDir = (payload.imagePath.match(/(.*)[\/\\]/)[1] || "") as string;
|
||||||
let outputDir = payload.outputPath as string;
|
let outputDir = payload.outputPath as string;
|
||||||
|
|
||||||
|
const isDefaultModel = defaultModels.includes(model);
|
||||||
|
|
||||||
// COPY IMAGE TO TMP FOLDER
|
// COPY IMAGE TO TMP FOLDER
|
||||||
const fullfileName = payload.imagePath.replace(/^.*[\\\/]/, "") as string;
|
const fullfileName = payload.imagePath.replace(/^.*[\\\/]/, "") as string;
|
||||||
|
|
||||||
@ -388,7 +402,7 @@ ipcMain.on(commands.UPSCAYL, async (event, payload) => {
|
|||||||
inputDir,
|
inputDir,
|
||||||
fullfileName,
|
fullfileName,
|
||||||
outFile,
|
outFile,
|
||||||
modelsPath,
|
isDefaultModel ? modelsPath : customModelsFolderPath ?? modelsPath,
|
||||||
model,
|
model,
|
||||||
scale,
|
scale,
|
||||||
gpuId,
|
gpuId,
|
||||||
@ -448,13 +462,16 @@ ipcMain.on(commands.FOLDER_UPSCAYL, async (event, payload) => {
|
|||||||
if (!fs.existsSync(outputDir)) {
|
if (!fs.existsSync(outputDir)) {
|
||||||
fs.mkdirSync(outputDir, { recursive: true });
|
fs.mkdirSync(outputDir, { recursive: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isDefaultModel = defaultModels.includes(model);
|
||||||
|
|
||||||
// UPSCALE
|
// UPSCALE
|
||||||
const upscayl = spawnUpscayl(
|
const upscayl = spawnUpscayl(
|
||||||
"realesrgan",
|
"realesrgan",
|
||||||
getBatchArguments(
|
getBatchArguments(
|
||||||
inputDir,
|
inputDir,
|
||||||
outputDir,
|
outputDir,
|
||||||
modelsPath,
|
isDefaultModel ? modelsPath : customModelsFolderPath ?? modelsPath,
|
||||||
model,
|
model,
|
||||||
gpuId,
|
gpuId,
|
||||||
saveImageAs
|
saveImageAs
|
||||||
|
@ -5,10 +5,12 @@ export type TModelsList = {
|
|||||||
value: string;
|
value: string;
|
||||||
}[];
|
}[];
|
||||||
|
|
||||||
export const modelsListAtom = atom<TModelsList>([
|
export const defaultModelsList = [
|
||||||
{ label: "General Photo (Real-ESRGAN)", value: "realesrgan-x4plus" },
|
{ label: "General Photo (Real-ESRGAN)", value: "realesrgan-x4plus" },
|
||||||
{ label: "General Photo (Remacri)", value: "remacri" },
|
{ label: "General Photo (Remacri)", value: "remacri" },
|
||||||
{ label: "General Photo (Ultramix Balanced)", value: "ultramix_balanced" },
|
{ label: "General Photo (Ultramix Balanced)", value: "ultramix_balanced" },
|
||||||
{ label: "General Photo (Ultrasharp)", value: "ultrasharp" },
|
{ label: "General Photo (Ultrasharp)", value: "ultrasharp" },
|
||||||
{ label: "Digital Art", value: "realesrgan-x4plus-anime" },
|
{ label: "Digital Art", value: "realesrgan-x4plus-anime" },
|
||||||
]);
|
];
|
||||||
|
|
||||||
|
export const modelsListAtom = atom<TModelsList>(defaultModelsList);
|
||||||
|
Loading…
Reference in New Issue
Block a user