Spaces:
Runtime error
Runtime error
errors msg
Browse files- frontend/src/lib/App.svelte +2 -2
- frontend/src/lib/Menu.svelte +2 -2
- frontend/src/lib/PaintFrame.svelte +12 -1
- stablediffusion-infinity/app.py +23 -23
frontend/src/lib/App.svelte
CHANGED
@@ -119,7 +119,7 @@
|
|
119 |
const imgBase64 = data.output.data[0] as string;
|
120 |
const isNSWF = data.output.data[1] as boolean;
|
121 |
if (isNSWF) {
|
122 |
-
throw new Error('
|
123 |
}
|
124 |
const imgBlob = await base64ToBlob(imgBase64);
|
125 |
const imgURL = await uploadImage(imgBlob, prompt);
|
@@ -197,7 +197,7 @@
|
|
197 |
</div>
|
198 |
|
199 |
<div class="fixed bottom-0 left-0 right-0 z-10 my-2">
|
200 |
-
<Menu on:prompt={onPrompt} />
|
201 |
</div>
|
202 |
|
203 |
<style lang="postcss" scoped>
|
|
|
119 |
const imgBase64 = data.output.data[0] as string;
|
120 |
const isNSWF = data.output.data[1] as boolean;
|
121 |
if (isNSWF) {
|
122 |
+
throw new Error('NFSW');
|
123 |
}
|
124 |
const imgBlob = await base64ToBlob(imgBase64);
|
125 |
const imgURL = await uploadImage(imgBlob, prompt);
|
|
|
197 |
</div>
|
198 |
|
199 |
<div class="fixed bottom-0 left-0 right-0 z-10 my-2">
|
200 |
+
<Menu on:prompt={onPrompt} {isLoading} />
|
201 |
</div>
|
202 |
|
203 |
<style lang="postcss" scoped>
|
frontend/src/lib/Menu.svelte
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
import { onMount, createEventDispatcher } from 'svelte';
|
3 |
import PPButton from '$lib/Buttons/PPButton.svelte';
|
4 |
const dispatch = createEventDispatcher();
|
5 |
-
|
6 |
const onKeyup = (e: KeyboardEvent) => {
|
7 |
if (e.key === 'Enter') {
|
8 |
dispatch('prompt');
|
@@ -17,5 +17,5 @@
|
|
17 |
</script>
|
18 |
|
19 |
<div class="grid grid-cols-1 gap-3 w-max mx-auto">
|
20 |
-
<PPButton on:click={() => dispatch('prompt')} />
|
21 |
</div>
|
|
|
2 |
import { onMount, createEventDispatcher } from 'svelte';
|
3 |
import PPButton from '$lib/Buttons/PPButton.svelte';
|
4 |
const dispatch = createEventDispatcher();
|
5 |
+
export let isLoading = false;
|
6 |
const onKeyup = (e: KeyboardEvent) => {
|
7 |
if (e.key === 'Enter') {
|
8 |
dispatch('prompt');
|
|
|
17 |
</script>
|
18 |
|
19 |
<div class="grid grid-cols-1 gap-3 w-max mx-auto">
|
20 |
+
<PPButton {isLoading} on:click={() => dispatch('prompt')} />
|
21 |
</div>
|
frontend/src/lib/PaintFrame.svelte
CHANGED
@@ -13,7 +13,7 @@
|
|
13 |
import { onMount, createEventDispatcher } from 'svelte';
|
14 |
|
15 |
import { useMyPresence } from '$lib/liveblocks';
|
16 |
-
import { canvasEl, maskEl } from '$lib/store';
|
17 |
|
18 |
import { Status } from './types';
|
19 |
const myPresence = useMyPresence();
|
@@ -218,6 +218,17 @@
|
|
218 |
<div class="py-3">
|
219 |
<PPButton {isLoading} on:click={() => dispatch('prompt')} />
|
220 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
221 |
</div>
|
222 |
<div
|
223 |
class="absolute left-full"
|
|
|
13 |
import { onMount, createEventDispatcher } from 'svelte';
|
14 |
|
15 |
import { useMyPresence } from '$lib/liveblocks';
|
16 |
+
import { canvasEl, maskEl, loadingState } from '$lib/store';
|
17 |
|
18 |
import { Status } from './types';
|
19 |
const myPresence = useMyPresence();
|
|
|
218 |
<div class="py-3">
|
219 |
<PPButton {isLoading} on:click={() => dispatch('prompt')} />
|
220 |
</div>
|
221 |
+
{#if $loadingState !== ''}
|
222 |
+
<div class="p-3 bg-white rounded-lg font-mono">
|
223 |
+
{#if $loadingState === 'NFSW'}
|
224 |
+
<h2 class="text-red-500 text-2xl font-bold">NSFW Alert</h2>
|
225 |
+
<h3 class="text-red-500 text-lg">
|
226 |
+
Possible NSFW result detected, please try again
|
227 |
+
</h3>
|
228 |
+
{/if}
|
229 |
+
<p>{$loadingState}</p>
|
230 |
+
</div>
|
231 |
+
{/if}
|
232 |
</div>
|
233 |
<div
|
234 |
class="absolute left-full"
|
stablediffusion-infinity/app.py
CHANGED
@@ -104,29 +104,29 @@ def run_outpaint(
|
|
104 |
process_size = 512
|
105 |
|
106 |
mask_sum = mask.sum()
|
107 |
-
if mask_sum >= WHITES:
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
print("inpainting")
|
131 |
img, mask = functbl[fill_mode](img, mask)
|
132 |
init_image = Image.fromarray(img)
|
|
|
104 |
process_size = 512
|
105 |
|
106 |
mask_sum = mask.sum()
|
107 |
+
# if mask_sum >= WHITES:
|
108 |
+
# print("inpaiting with fixed Mask")
|
109 |
+
# mask = np.array(MASK)[:, :, 0]
|
110 |
+
# img, mask = functbl[fill_mode](img, mask)
|
111 |
+
# init_image = Image.fromarray(img)
|
112 |
+
# mask = 255 - mask
|
113 |
+
# mask = skimage.measure.block_reduce(mask, (8, 8), np.max)
|
114 |
+
# mask = mask.repeat(8, axis=0).repeat(8, axis=1)
|
115 |
+
# mask_image = Image.fromarray(mask)
|
116 |
+
|
117 |
+
# # mask_image=mask_image.filter(ImageFilter.GaussianBlur(radius = 8))
|
118 |
+
# with autocast("cuda"):
|
119 |
+
# images = inpaint(
|
120 |
+
# prompt=prompt_text,
|
121 |
+
# init_image=init_image.resize(
|
122 |
+
# (process_size, process_size), resample=SAMPLING_MODE
|
123 |
+
# ),
|
124 |
+
# mask_image=mask_image.resize((process_size, process_size)),
|
125 |
+
# strength=strength,
|
126 |
+
# num_inference_steps=step,
|
127 |
+
# guidance_scale=guidance,
|
128 |
+
# )
|
129 |
+
if mask_sum > 0:
|
130 |
print("inpainting")
|
131 |
img, mask = functbl[fill_mode](img, mask)
|
132 |
init_image = Image.fromarray(img)
|