Skip to content

Commit 1587751

Browse files
committed
Fix bug
1 parent db83ede commit 1587751

File tree

14 files changed

+126
-32
lines changed

14 files changed

+126
-32
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# 소개
2-
Stable Diffusion 계열 API와 모델을 사용하기 편하게 해주는 프론트앤드 프로그램입니다. 모든 씬을 여러번 생성 예약을 해놓고 딴거하다가 와서 이미지를 이상형 월드컵으로 선택하고 리터칭하는 작업 흐름에 맞춰져 있습니다.
2+
Stable Diffusion 계열 API와 모델을 사용하기 편하게 해주는 프론트앤드 프로그램입니다. 모든 씬을 여러번 생성 예약을 해놓고 딴거하다가 와서 이미지를 이미지 월드컵으로 선택하고 리터칭하는 작업 흐름에 맞춰져 있습니다.
33

44
![](images/img1.png)
55

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"url": "https://sunho.io"
2020
},
2121
"main": "./src/main/main.ts",
22-
"version": "3.1.10",
22+
"version": "3.1.11",
2323
"scripts": {
2424
"build": "concurrently \"npm run build:main\" \"npm run build:renderer\"",
2525
"build:dll": "cross-env NODE_ENV=development TS_NODE_TRANSPILE_ONLY=true webpack --config ./.erb/configs/webpack.config.renderer.dev.dll.ts",

release/app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "SDStudio",
3-
"version": "3.1.10",
3+
"version": "3.1.11",
44
"description": "A foundation for scalable desktop apps",
55
"license": "MIT",
66
"author": {

src/main/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ export interface Config {
2121
uuid?: string;
2222
whiteMode?: boolean;
2323
disableQuality?: boolean;
24+
useAnimalModel?: boolean;
2425
}

src/renderer/backends/genVendors/nai.ts

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,6 @@ export class NovelAiImageGenService implements ImageGenService {
3737
return modelMap[model];
3838
}
3939

40-
private translateResolution(resolution: Resolution): {
41-
height: number;
42-
width: number;
43-
} {
44-
const resolutionMap = {
45-
small_landscape: { height: 512, width: 768 },
46-
small_portrait: { height: 768, width: 512 },
47-
small_square: { height: 640, width: 640 },
48-
landscape: { height: 832, width: 1216 },
49-
portrait: { height: 1216, width: 832 },
50-
square: { height: 1024, width: 1024 },
51-
large_landscape: { height: 1024, width: 1536 },
52-
large_portrait: { height: 1536, width: 1024 },
53-
large_square: { height: 1472, width: 1472 },
54-
wallpaper_portrait: { height: 1088, width: 1920 },
55-
wallpaper_landscape: { height: 1920, width: 1088 },
56-
} as const;
57-
return resolutionMap[resolution];
58-
}
59-
6040
private translateSampling(sampling: Sampling): string {
6141
const samplingMap = {
6242
k_euler_ancestral: 'k_euler_ancestral',
@@ -116,11 +96,16 @@ export class NovelAiImageGenService implements ImageGenService {
11696
}
11797

11898
public async generateImage(authorization: string, params: ImageGenInput) {
119-
const modelValue = this.translateModel(params.model);
120-
const resolutionValue = this.translateResolution(params.resolution);
99+
let modelValue = this.translateModel(params.model);
100+
const resolutionValue = params.resolution;
121101
const samplingValue = this.translateSampling(params.sampling);
122102

123103
const config = await backend.getConfig();
104+
if (config.useAnimalModel) {
105+
if (params.model === Model.Anime) {
106+
modelValue = 'nai-diffusion-furry-3';
107+
}
108+
}
124109

125110
const seed = params.seed ?? this.getRandomInt(1, 2100000000);
126111
let action = undefined;

src/renderer/backends/imageGen.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export enum Resolution {
1616
LargeSquare = 'large_square',
1717
WallpaperPortrait = 'wallpaper_portrait',
1818
WallpaperLandscape = 'wallpaper_landscape',
19+
Custom = 'custom',
1920
}
2021

2122
export const upscaleReoslution = (resolution: Resolution) => {
@@ -36,6 +37,8 @@ export const upscaleReoslution = (resolution: Resolution) => {
3637
return Resolution.WallpaperPortrait;
3738
case Resolution.WallpaperLandscape:
3839
return Resolution.WallpaperLandscape;
40+
case Resolution.Custom:
41+
return Resolution.Custom;
3942
default:
4043
return resolution;
4144
}
@@ -53,8 +56,16 @@ export const resolutionMap = {
5356
large_square: { height: 1472, width: 1472 },
5457
wallpaper_portrait: { height: 1088, width: 1920 },
5558
wallpaper_landscape: { height: 1920, width: 1088 },
59+
custom: { height: 0, width: 0 },
5660
} as const;
5761

62+
export const convertResolution = (resolution: Resolution): ImageSize => {
63+
return {
64+
width: resolutionMap[resolution].width,
65+
height: resolutionMap[resolution].height,
66+
}
67+
};
68+
5869
export enum Sampling {
5970
KEulerAncestral = 'k_euler_ancestral',
6071
KEuler = 'k_euler',
@@ -77,11 +88,16 @@ export interface Vibe {
7788
strength: number;
7889
}
7990

91+
export interface ImageSize {
92+
width: number;
93+
height: number;
94+
}
95+
8096
export interface ImageGenInput {
8197
model: Model;
8298
prompt: string;
8399
uc: string;
84-
resolution: Resolution;
100+
resolution: ImageSize;
85101
sampling: Sampling;
86102
outputFilePath: string;
87103
sm: boolean;

src/renderer/componenets/App.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ input[type='number']::-webkit-outer-spin-button {
345345
.canvas-tooltip {
346346
position: absolute;
347347
right: 0;
348-
bottom: 0;
348+
bottom: 50px;
349349
padding: 5px;
350350
z-index: 3;
351351
background: white;

src/renderer/componenets/ConfigScreen.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const ConfigScreen = observer(({ onSave }: ConfigScreenProps) => {
2222
const [whiteMode, setWhiteMode] = useState(false);
2323
const [noIpCheck, setNoIpCheck] = useState(false);
2424
const [disableQuality, setDisableQuality] = useState(false);
25+
const [animalModel, setAnimalModel] = useState(false);
2526
const [useLocalBgRemoval, setUseLocalBgRemoval] = useState(false);
2627
const [refreshImage, setRefreshImage] = useState(false);
2728
const [ready, setReady] = useState(false);
@@ -41,6 +42,8 @@ const ConfigScreen = observer(({ onSave }: ConfigScreenProps) => {
4142
setNoIpCheck(config.noIpCheck ?? false);
4243
setRefreshImage(config.refreshImage ?? false);
4344
setUseLocalBgRemoval(config.useLocalBgRemoval ?? false);
45+
setDisableQuality(config.disableQuality ?? false);
46+
setAnimalModel(config.useAnimalModel ?? false);
4447
})();
4548
const checkReady = () => {
4649
setReady(localAIService.ready);
@@ -308,6 +311,16 @@ const ConfigScreen = observer(({ onSave }: ConfigScreenProps) => {
308311
onChange={(e) => setDisableQuality(e.target.checked)}
309312
/>
310313
</div>
314+
<div className="mt-4 flex items-center gap-2">
315+
<label htmlFor="whiteMode" className="text-sm gray-label">
316+
NAI 동물 모델 사용
317+
</label>
318+
<input
319+
type="checkbox"
320+
checked={animalModel}
321+
onChange={(e) => setAnimalModel(e.target.checked)}
322+
/>
323+
</div>
311324
<button
312325
className="mt-4 w-full back-sky py-2 rounded hover:brightness-95 active:brightness-90"
313326
onClick={async () => {
@@ -322,6 +335,7 @@ const ConfigScreen = observer(({ onSave }: ConfigScreenProps) => {
322335
disableQuality: disableQuality,
323336
whiteMode: whiteMode,
324337
useLocalBgRemoval: useLocalBgRemoval,
338+
useAnimalModel: animalModel,
325339
};
326340
await backend.setConfig(config);
327341
if (old.useCUDA !== useGPU) localAIService.modelChanged();

src/renderer/componenets/InPaintEditor.tsx

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ const InPaintEditor = observer(
5252
const { curSession } = appState;
5353
const resolutionOptions = Object.entries(resolutionMap)
5454
.map(([key, value]) => {
55+
const resolVal = (editingScene.resolutionWidth ?? '') + 'x' + (editingScene.resolutionHeight ?? '');
56+
if (key === 'custom') return { label: '커스텀 (' + resolVal + ')', value: key };
5557
return { label: `${value.width}x${value.height}`, value: key };
5658
})
5759
.filter((x) => !x.value.startsWith('small'));
@@ -138,7 +140,7 @@ const InPaintEditor = observer(
138140
});
139141
};
140142

141-
const confirm = async () => {
143+
const saveMask = async () => {
142144
if (def.hasMask) {
143145
const mask = await brushTool.current!.getMaskBase64();
144146
if (!editingScene.preset.mask) {
@@ -154,6 +156,10 @@ const InPaintEditor = observer(
154156
);
155157
}
156158
}
159+
};
160+
161+
const confirm = async () => {
162+
await saveMask();
157163
onConfirm();
158164
};
159165

@@ -191,7 +197,7 @@ const InPaintEditor = observer(
191197
options={resolutionOptions}
192198
menuPlacement="bottom"
193199
selectedOption={editingScene.resolution}
194-
onSelect={(opt) => {
200+
onSelect={async (opt) => {
195201
if (
196202
opt.value.startsWith('large') ||
197203
opt.value.startsWith('wallpaper')
@@ -203,6 +209,25 @@ const InPaintEditor = observer(
203209
editingScene.resolution = opt.value as Resolution;
204210
},
205211
});
212+
} else if (opt.value === 'custom') {
213+
const width = await appState.pushDialogAsync({
214+
type: 'input-confirm',
215+
text: '해상도 너비를 입력해주세요'
216+
});
217+
if (width == null) return;
218+
const height = await appState.pushDialogAsync({
219+
type: 'input-confirm',
220+
text: '해상도 높이를 입력해주세요'
221+
});
222+
if (height == null) return;
223+
try {
224+
const customResolution = { width: parseInt(width), height: parseInt(height) };
225+
editingScene.resolution = opt.value as Resolution;
226+
editingScene.resolutionWidth = (customResolution.width + 63) & ~63;
227+
editingScene.resolutionHeight = (customResolution.height + 63) & ~63;
228+
} catch (e: any) {
229+
appState.pushMessage(e.message);
230+
}
206231
} else {
207232
editingScene.resolution = opt.value as Resolution;
208233
}
@@ -317,6 +342,7 @@ const InPaintEditor = observer(
317342
<button
318343
className={`round-button back-green h-8 w-16 md:w-36 flex items-center justify-center`}
319344
onClick={async () => {
345+
await saveMask();
320346
await queueI2IWorkflow(curSession!, editingScene.workflowType, editingScene.preset, editingScene, 1, (path: string) => {
321347
(async () => {
322348
const data = await imageService.fetchImage(path);

src/renderer/componenets/SceneEditor.tsx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,8 @@ const SceneEditor = observer(({ scene, onClosed, onDeleted }: Props) => {
547547

548548
const resolutionOptions = Object.entries(resolutionMap)
549549
.map(([key, value]) => {
550+
const resolVal = (scene.resolutionWidth ?? '') + 'x' + (scene.resolutionHeight ?? '');
551+
if (key === 'custom') return { label: '커스텀 (' + resolVal + ')', value: key };
550552
return { label: `${value.width}x${value.height}`, value: key };
551553
})
552554
.filter((x) => !x.value.startsWith('small'));
@@ -573,7 +575,7 @@ const SceneEditor = observer(({ scene, onClosed, onDeleted }: Props) => {
573575
options={resolutionOptions}
574576
menuPlacement="bottom"
575577
selectedOption={scene.resolution}
576-
onSelect={(opt) => {
578+
onSelect={async (opt) => {
577579
if (
578580
opt.value.startsWith('large') ||
579581
opt.value.startsWith('wallpaper')
@@ -585,6 +587,25 @@ const SceneEditor = observer(({ scene, onClosed, onDeleted }: Props) => {
585587
scene.resolution = opt.value as Resolution;
586588
},
587589
});
590+
} else if (opt.value === 'custom') {
591+
const width = await appState.pushDialogAsync({
592+
type: 'input-confirm',
593+
text: '해상도 너비를 입력해주세요'
594+
});
595+
if (width == null) return;
596+
const height = await appState.pushDialogAsync({
597+
type: 'input-confirm',
598+
text: '해상도 높이를 입력해주세요'
599+
});
600+
if (height == null) return;
601+
try {
602+
const customResolution = { width: parseInt(width), height: parseInt(height) };
603+
scene.resolution = opt.value as Resolution;
604+
scene.resolutionWidth = (customResolution.width + 63) & ~63;
605+
scene.resolutionHeight = (customResolution.height + 63) & ~63;
606+
} catch (e: any) {
607+
appState.pushMessage(e.message);
608+
}
588609
} else {
589610
scene.resolution = opt.value as Resolution;
590611
}

0 commit comments

Comments
 (0)