Spaces:
Sleeping
Sleeping
new
Browse files
app_init.py
CHANGED
@@ -139,7 +139,8 @@ def init_app(app: FastAPI, user_queue_map: UserQueueDict, args: Args, pipeline):
|
|
139 |
# route to setup frontend
|
140 |
@app.get("/settings")
|
141 |
async def settings():
|
142 |
-
|
143 |
-
|
|
|
144 |
|
145 |
app.mount("/", StaticFiles(directory="public", html=True), name="public")
|
|
|
139 |
# route to setup frontend
|
140 |
@app.get("/settings")
|
141 |
async def settings():
|
142 |
+
info = pipeline.Info.schema()
|
143 |
+
input_params = pipeline.InputParams.schema()
|
144 |
+
return JSONResponse({"info": info, "input_params": input_params})
|
145 |
|
146 |
app.mount("/", StaticFiles(directory="public", html=True), name="public")
|
frontend/src/lib/components/Button.svelte
CHANGED
@@ -1,4 +1,10 @@
|
|
1 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
<style lang="postcss">
|
4 |
.button {
|
|
|
1 |
+
<script lang="ts">
|
2 |
+
export let classList: string = '';
|
3 |
+
</script>
|
4 |
+
|
5 |
+
<button class="button {classList}" on:click>
|
6 |
+
<slot />
|
7 |
+
</button>
|
8 |
|
9 |
<style lang="postcss">
|
10 |
.button {
|
frontend/src/lib/components/InputRange.svelte
CHANGED
@@ -24,6 +24,6 @@
|
|
24 |
type="number"
|
25 |
step={params?.step ?? 1}
|
26 |
bind:value
|
27 |
-
class="rounded-md border border-gray-700 px-1 py-1 text-center text-xs font-
|
28 |
/>
|
29 |
</div>
|
|
|
24 |
type="number"
|
25 |
step={params?.step ?? 1}
|
26 |
bind:value
|
27 |
+
class="rounded-md border border-gray-700 px-1 py-1 text-center text-xs font-bold dark:text-black"
|
28 |
/>
|
29 |
</div>
|
frontend/src/lib/icons/spinner.svelte
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script lang="ts">
|
2 |
+
export let classList: string;
|
3 |
+
</script>
|
4 |
+
|
5 |
+
<svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 512 512" class={classList}>
|
6 |
+
<path
|
7 |
+
fill="currentColor"
|
8 |
+
d="M304 48a48 48 0 1 0 -96 0 48 48 0 1 0 96 0zm0 416a48 48 0 1 0 -96 0 48 48 0 1 0 96 0zM48 304a48 48 0 1 0 0-96 48 48 0 1 0 0 96zm464-48a48 48 0 1 0 -96 0 48 48 0 1 0 96 0zM142.9 437A48 48 0 1 0 75 369.1 48 48 0 1 0 142.9 437zm0-294.2A48 48 0 1 0 75 75a48 48 0 1 0 67.9 67.9zM369.1 437A48 48 0 1 0 437 369.1 48 48 0 1 0 369.1 437z"
|
9 |
+
/>
|
10 |
+
</svg>
|
frontend/src/lib/types.ts
CHANGED
@@ -13,4 +13,9 @@ export interface FieldProps {
|
|
13 |
step?: number;
|
14 |
disabled?: boolean;
|
15 |
hide?: boolean;
|
|
|
|
|
|
|
|
|
|
|
16 |
}
|
|
|
13 |
step?: number;
|
14 |
disabled?: boolean;
|
15 |
hide?: boolean;
|
16 |
+
}
|
17 |
+
export interface PipelineInfo {
|
18 |
+
name: string;
|
19 |
+
description: string;
|
20 |
+
mode: string;
|
21 |
}
|
frontend/src/routes/+page.svelte
CHANGED
@@ -1,13 +1,15 @@
|
|
1 |
<script lang="ts">
|
2 |
import { onMount } from 'svelte';
|
3 |
import { PUBLIC_BASE_URL } from '$env/static/public';
|
4 |
-
import type { FieldProps } from '$lib/types';
|
5 |
import ImagePlayer from '$lib/components/ImagePlayer.svelte';
|
6 |
import VideoInput from '$lib/components/VideoInput.svelte';
|
7 |
import Button from '$lib/components/Button.svelte';
|
8 |
import PipelineOptions from '$lib/components/PipelineOptions.svelte';
|
|
|
9 |
|
10 |
let pipelineParams: FieldProps[];
|
|
|
11 |
let pipelineValues = {};
|
12 |
|
13 |
onMount(() => {
|
@@ -16,8 +18,10 @@
|
|
16 |
|
17 |
async function getSettings() {
|
18 |
const settings = await fetch(`${PUBLIC_BASE_URL}/settings`).then((r) => r.json());
|
19 |
-
pipelineParams = Object.values(settings.properties);
|
|
|
20 |
pipelineParams = pipelineParams.filter((e) => e?.disabled !== true);
|
|
|
21 |
}
|
22 |
|
23 |
$: {
|
@@ -53,24 +57,32 @@
|
|
53 |
> and run it on your own GPU.
|
54 |
</p>
|
55 |
</article>
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
<
|
67 |
-
|
68 |
-
|
69 |
-
|
|
|
70 |
|
71 |
-
|
72 |
-
|
73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
</main>
|
75 |
|
76 |
<style lang="postcss">
|
|
|
1 |
<script lang="ts">
|
2 |
import { onMount } from 'svelte';
|
3 |
import { PUBLIC_BASE_URL } from '$env/static/public';
|
4 |
+
import type { FieldProps, PipelineInfo } from '$lib/types';
|
5 |
import ImagePlayer from '$lib/components/ImagePlayer.svelte';
|
6 |
import VideoInput from '$lib/components/VideoInput.svelte';
|
7 |
import Button from '$lib/components/Button.svelte';
|
8 |
import PipelineOptions from '$lib/components/PipelineOptions.svelte';
|
9 |
+
import Spinner from '$lib/icons/spinner.svelte';
|
10 |
|
11 |
let pipelineParams: FieldProps[];
|
12 |
+
let pipelineInfo: PipelineInfo;
|
13 |
let pipelineValues = {};
|
14 |
|
15 |
onMount(() => {
|
|
|
18 |
|
19 |
async function getSettings() {
|
20 |
const settings = await fetch(`${PUBLIC_BASE_URL}/settings`).then((r) => r.json());
|
21 |
+
pipelineParams = Object.values(settings.input_params.properties);
|
22 |
+
pipelineInfo = settings.info.properties;
|
23 |
pipelineParams = pipelineParams.filter((e) => e?.disabled !== true);
|
24 |
+
console.log('SETTINGS', pipelineInfo);
|
25 |
}
|
26 |
|
27 |
$: {
|
|
|
57 |
> and run it on your own GPU.
|
58 |
</p>
|
59 |
</article>
|
60 |
+
{#if pipelineParams}
|
61 |
+
<h2 class="font-medium">Prompt</h2>
|
62 |
+
<p class="text-sm text-gray-500">
|
63 |
+
Change the prompt to generate different images, accepts <a
|
64 |
+
href="https://github.com/damian0815/compel/blob/main/doc/syntax.md"
|
65 |
+
target="_blank"
|
66 |
+
class="text-blue-500 underline hover:no-underline">Compel</a
|
67 |
+
> syntax.
|
68 |
+
</p>
|
69 |
+
<PipelineOptions {pipelineParams} bind:pipelineValues></PipelineOptions>
|
70 |
+
<div class="flex gap-3">
|
71 |
+
<Button>Start</Button>
|
72 |
+
<Button>Stop</Button>
|
73 |
+
<Button classList={'ml-auto'}>Snapshot</Button>
|
74 |
+
</div>
|
75 |
|
76 |
+
<ImagePlayer>
|
77 |
+
<VideoInput></VideoInput>
|
78 |
+
</ImagePlayer>
|
79 |
+
{:else}
|
80 |
+
<!-- loading -->
|
81 |
+
<div class="flex items-center justify-center gap-3 py-48 text-2xl">
|
82 |
+
<Spinner classList={'animate-spin opacity-50'}></Spinner>
|
83 |
+
<p>Loading...</p>
|
84 |
+
</div>
|
85 |
+
{/if}
|
86 |
</main>
|
87 |
|
88 |
<style lang="postcss">
|
pipelines/txt2img.py
CHANGED
@@ -20,6 +20,10 @@ default_prompt = "Portrait of The Terminator with , glare pose, detailed, intric
|
|
20 |
|
21 |
|
22 |
class Pipeline:
|
|
|
|
|
|
|
|
|
23 |
class InputParams(BaseModel):
|
24 |
prompt: str = Field(
|
25 |
default_prompt,
|
|
|
20 |
|
21 |
|
22 |
class Pipeline:
|
23 |
+
class Info(BaseModel):
|
24 |
+
name: str = "txt2img"
|
25 |
+
description: str = "Generates an image from a text prompt"
|
26 |
+
|
27 |
class InputParams(BaseModel):
|
28 |
prompt: str = Field(
|
29 |
default_prompt,
|