Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
some ui improvement
Browse files- src/lib/components/Button.svelte +1 -1
- src/lib/components/community/drawer/Drawer.svelte +3 -1
- src/lib/components/generate/Response.svelte +20 -7
- src/lib/components/models/drawer/Drawer.svelte +6 -2
- src/lib/components/sidebar/Sidebar.svelte +7 -5
- src/lib/components/spaceheader/SpaceMiniHeader.svelte +5 -5
- src/routes/api/models/+server.ts +4 -0
- src/routes/generate/+page.svelte +1 -1
src/lib/components/Button.svelte
CHANGED
@@ -26,7 +26,7 @@
|
|
26 |
</script>
|
27 |
|
28 |
<button
|
29 |
-
class="button {theme} {size} relative whitespace-nowrap {disabled ? 'disabled' : ''}"
|
30 |
class:!bg-neutral-400={loading}
|
31 |
class:!border-neutral-400={loading}
|
32 |
class:!grayscale={disabled}
|
|
|
26 |
</script>
|
27 |
|
28 |
<button
|
29 |
+
class="button {theme} {size} relative whitespace-nowrap {disabled ? 'disabled' : ''} focus:ring-[4px] focus:ring-white focus:ring-opacity-20 focus:brightness-125"
|
30 |
class:!bg-neutral-400={loading}
|
31 |
class:!border-neutral-400={loading}
|
32 |
class:!grayscale={disabled}
|
src/lib/components/community/drawer/Drawer.svelte
CHANGED
@@ -83,7 +83,9 @@
|
|
83 |
<div class="w-full col-span-2">
|
84 |
<Reactions reactions={gallery?.reactions} gallery_id={gallery.id} />
|
85 |
</div>
|
86 |
-
<
|
|
|
|
|
87 |
<div class="col-span-2">
|
88 |
<button
|
89 |
class="flex items-center justify-start gap-4 cursor-pointer w-full text-left transition-all duration-200 hover:bg-neutral-900 p-3 group relative rounded-lg"
|
|
|
83 |
<div class="w-full col-span-2">
|
84 |
<Reactions reactions={gallery?.reactions} gallery_id={gallery.id} />
|
85 |
</div>
|
86 |
+
<a href="/api/images/{gallery?.image}" target="_blank" class="w-full max-w-[450px] col-span-2">
|
87 |
+
<img src="/api/images/{gallery?.image}" class="w-full h-[450px] bg-neutral-800 object-cover rounded-xl" alt={gallery?.prompt} />
|
88 |
+
</a>
|
89 |
<div class="col-span-2">
|
90 |
<button
|
91 |
class="flex items-center justify-start gap-4 cursor-pointer w-full text-left transition-all duration-200 hover:bg-neutral-900 p-3 group relative rounded-lg"
|
src/lib/components/generate/Response.svelte
CHANGED
@@ -2,6 +2,8 @@
|
|
2 |
import { generationStore } from "$lib/stores/use-generation";
|
3 |
import Button from "$lib/components/Button.svelte";
|
4 |
import { userStore } from "$lib/stores/use-user";
|
|
|
|
|
5 |
|
6 |
export let loading_generation: boolean = false;
|
7 |
|
@@ -60,6 +62,11 @@
|
|
60 |
const milliseconds = Math.round(date.getMilliseconds() / 100);
|
61 |
return `${seconds}.${milliseconds}s`;
|
62 |
}
|
|
|
|
|
|
|
|
|
|
|
63 |
</script>
|
64 |
|
65 |
<div class=" w-full border-t xl:border-t-0 xl:border-l border-neutral-800 h-full col-span-5 xl:col-span-2" class:!border-black={!$generationStore?.image || loading_generation}>
|
@@ -100,16 +107,22 @@
|
|
100 |
{#if $generationStore?.form}
|
101 |
<div class="mt-6 grid grid-cols-1 gap-4">
|
102 |
<div>
|
103 |
-
<p class="text-neutral-400 font-semibold text-xs uppercase">
|
104 |
Model selected
|
105 |
</p>
|
106 |
-
<
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
|
|
|
|
|
|
|
|
|
|
112 |
</div>
|
|
|
113 |
</div>
|
114 |
<div>
|
115 |
<p class="text-neutral-400 font-semibold text-xs uppercase">
|
|
|
2 |
import { generationStore } from "$lib/stores/use-generation";
|
3 |
import Button from "$lib/components/Button.svelte";
|
4 |
import { userStore } from "$lib/stores/use-user";
|
5 |
+
import Icon from "@iconify/svelte";
|
6 |
+
import { goto } from "$app/navigation";
|
7 |
|
8 |
export let loading_generation: boolean = false;
|
9 |
|
|
|
62 |
const milliseconds = Math.round(date.getMilliseconds() / 100);
|
63 |
return `${seconds}.${milliseconds}s`;
|
64 |
}
|
65 |
+
|
66 |
+
const handleClickModel = (id?: string) => {
|
67 |
+
if (!id) return;
|
68 |
+
goto(`/models/${id}`);
|
69 |
+
};
|
70 |
</script>
|
71 |
|
72 |
<div class=" w-full border-t xl:border-t-0 xl:border-l border-neutral-800 h-full col-span-5 xl:col-span-2" class:!border-black={!$generationStore?.image || loading_generation}>
|
|
|
107 |
{#if $generationStore?.form}
|
108 |
<div class="mt-6 grid grid-cols-1 gap-4">
|
109 |
<div>
|
110 |
+
<p class="text-neutral-400 font-semibold text-xs uppercase mb-3">
|
111 |
Model selected
|
112 |
</p>
|
113 |
+
<button
|
114 |
+
class="flex items-center justify-start gap-4 cursor-pointer w-full text-left transition-all duration-200 hover:bg-neutral-900 p-3 group relative rounded-lg"
|
115 |
+
on:click={() => handleClickModel($generationStore?.form?.model.id)}
|
116 |
+
>
|
117 |
+
<img src={$generationStore?.form?.model.image} alt={$generationStore?.form?.model.title} class="w-14 h-14 rounded-lg object-cover" />
|
118 |
+
<div>
|
119 |
+
<p class="text-neutral-200 text-base font-medium">{$generationStore?.form?.model.id}</p>
|
120 |
+
<p class="text-neutral-400 text-sm">{$generationStore?.form?.model.id}</p>
|
121 |
+
</div>
|
122 |
+
<div class="rounded-full absolute top-1/2 -translate-y-1/2 text-neutral-100 w-8 h-8 right-4 bg-pink-500 flex items-center justify-center transition-all duration-200 group-hover:opacity-100 opacity-0">
|
123 |
+
<Icon icon="tabler:arrow-up" class="w-5 h-5 transform rotate-45 font-bold" />
|
124 |
</div>
|
125 |
+
</button>
|
126 |
</div>
|
127 |
<div>
|
128 |
<p class="text-neutral-400 font-semibold text-xs uppercase">
|
src/lib/components/models/drawer/Drawer.svelte
CHANGED
@@ -109,9 +109,9 @@
|
|
109 |
</p>
|
110 |
<div id="gallery_examples" class="w-full h-[300px] mt-2 flex flex-nowrap overflow-auto gap-5 relative">
|
111 |
{#each model?.gallery as example}
|
112 |
-
<
|
113 |
<img src="/api/images/{example.image}" class="w-full h-full bg-center bg-cover rounded-lg object-cover object-center bg-neutral-800" alt={example.prompt} />
|
114 |
-
</
|
115 |
{/each}
|
116 |
</div>
|
117 |
<div class="w-[100px] h-full absolute right-0 top-0 bg-gradient-to-r from-transparent to-neutral-950 flex items-center justify-end pr-4">
|
@@ -133,6 +133,10 @@
|
|
133 |
{/if}
|
134 |
{#if model?.infos}
|
135 |
<div class="bg-neutral-900/70 rounded-lg border border-neutral-800/20">
|
|
|
|
|
|
|
|
|
136 |
<div class="border-b border-neutral-800/80 px-4 py-3">
|
137 |
<p class="text-neutral-400 uppercase text-[10px]">license</p>
|
138 |
<p class="text-neutral-100 font-medium text-base mt-0.5">{model?.infos?.license ?? 'N/A'}</p>
|
|
|
109 |
</p>
|
110 |
<div id="gallery_examples" class="w-full h-[300px] mt-2 flex flex-nowrap overflow-auto gap-5 relative">
|
111 |
{#each model?.gallery as example}
|
112 |
+
<a href="/api/images/{example.image}" class="w-[300px] min-w-[300px] h-full relative" target="_blank">
|
113 |
<img src="/api/images/{example.image}" class="w-full h-full bg-center bg-cover rounded-lg object-cover object-center bg-neutral-800" alt={example.prompt} />
|
114 |
+
</a>
|
115 |
{/each}
|
116 |
</div>
|
117 |
<div class="w-[100px] h-full absolute right-0 top-0 bg-gradient-to-r from-transparent to-neutral-950 flex items-center justify-end pr-4">
|
|
|
133 |
{/if}
|
134 |
{#if model?.infos}
|
135 |
<div class="bg-neutral-900/70 rounded-lg border border-neutral-800/20">
|
136 |
+
<div class="border-b border-neutral-800/80 px-4 py-3">
|
137 |
+
<p class="text-neutral-400 uppercase text-[10px]">Instance Prompt</p>
|
138 |
+
<p class="text-neutral-100 font-medium text-base mt-0.5">{model?.instance_prompt ?? 'N/A'}</p>
|
139 |
+
</div>
|
140 |
<div class="border-b border-neutral-800/80 px-4 py-3">
|
141 |
<p class="text-neutral-400 uppercase text-[10px]">license</p>
|
142 |
<p class="text-neutral-100 font-medium text-base mt-0.5">{model?.infos?.license ?? 'N/A'}</p>
|
src/lib/components/sidebar/Sidebar.svelte
CHANGED
@@ -81,13 +81,15 @@
|
|
81 |
<div class="flex items-center justify-start gap-4">
|
82 |
<img src={$userStore?.picture?.startsWith('http') ? $userStore?.picture : `https://huggingface.co${$userStore?.picture}`} alt="User avatar" class="w-10 h-10 rounded-full border-2 border-white inline-block" />
|
83 |
<div class="w-full text-left">
|
84 |
-
<p class="text-lg font-semibold">
|
85 |
{$userStore.name}
|
86 |
-
|
87 |
-
|
|
|
|
|
|
|
88 |
{/if}
|
89 |
-
|
90 |
-
<p class="text-sm leading-none text-neutral-400">{$userStore.preferred_username}</p>
|
91 |
</div>
|
92 |
</div>
|
93 |
<button on:click={logout}>
|
|
|
81 |
<div class="flex items-center justify-start gap-4">
|
82 |
<img src={$userStore?.picture?.startsWith('http') ? $userStore?.picture : `https://huggingface.co${$userStore?.picture}`} alt="User avatar" class="w-10 h-10 rounded-full border-2 border-white inline-block" />
|
83 |
<div class="w-full text-left">
|
84 |
+
<p class="text-lg font-semibold truncate">
|
85 |
{$userStore.name}
|
86 |
+
</p>
|
87 |
+
<div class="flex items-center justify-start gap-1">
|
88 |
+
<p class="text-sm leading-none text-neutral-400">{$userStore.preferred_username}</p>
|
89 |
+
{#if $userStore?.is_admin}
|
90 |
+
<span class="text-yellow-400 bg-yellow-500 bg-opacity-20 rounded-lg px-2 py-0 text-[10px] font-medium inline-block whitespace-nowrap">HF Staff</span>
|
91 |
{/if}
|
92 |
+
</div>
|
|
|
93 |
</div>
|
94 |
</div>
|
95 |
<button on:click={logout}>
|
src/lib/components/spaceheader/SpaceMiniHeader.svelte
CHANGED
@@ -15,13 +15,13 @@
|
|
15 |
|
16 |
</script>
|
17 |
{#if space.id && isVisible}
|
18 |
-
<div class="from-gray-50 to-white text-md shadow-alternate fixed right-6 top-5 z-20 flex h-[40px] items-stretch gap-3 overflow-hidden rounded-xl
|
19 |
<div class="flex items-center justify-start gap-2">
|
20 |
<img src={`https://huggingface.co/api/users/${space.author}/avatar`} class="w-3.5 h-3.5 rounded-full flex-none" alt={space.author} />
|
21 |
<div class="flex items-center justify-center gap-1">
|
22 |
-
<a href="https://huggingface.co/{space.author}" class="text-gray-500 hover:text-blue-600" target="_blank">{space.author}</a>
|
23 |
-
<span class="text-gray-300 text-lg">/</span>
|
24 |
-
<a href="https://huggingface.co/spaces/{space.id}" target="_blank" class="font-mono font-
|
25 |
</div>
|
26 |
</div>
|
27 |
<div class="inline-flex items-center overflow-hidden whitespace-nowrap rounded-md border bg-white text-sm leading-none text-gray-500 flex-none self-center "><button class="relative flex items-center overflow-hidden from-red-50 to-transparent dark:from-red-900 p-1 focus:outline-none" title="Unlike"><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32" fill="currentColor"><path d="M22.45,6a5.47,5.47,0,0,1,3.91,1.64,5.7,5.7,0,0,1,0,8L16,26.13,5.64,15.64a5.7,5.7,0,0,1,0-8,5.48,5.48,0,0,1,7.82,0L16,10.24l2.53-2.58A5.44,5.44,0,0,1,22.45,6m0-2a7.47,7.47,0,0,0-5.34,2.24L16,7.36,14.89,6.24a7.49,7.49,0,0,0-10.68,0,7.72,7.72,0,0,0,0,10.82L16,29,27.79,17.06a7.72,7.72,0,0,0,0-10.82A7.49,7.49,0,0,0,22.45,4Z"></path></svg> <svg class="absolute text-red-500 origin-center transform transition-transform ease-in
|
@@ -35,6 +35,6 @@
|
|
35 |
font-family: "IBM Plex Mono", sans-serif;
|
36 |
}
|
37 |
.font-other {
|
38 |
-
font-family: "
|
39 |
}
|
40 |
</style>
|
|
|
15 |
|
16 |
</script>
|
17 |
{#if space.id && isVisible}
|
18 |
+
<div class="from-gray-50 to-white text-md shadow-alternate fixed right-6 top-5 z-20 flex h-[40px] items-stretch gap-3 overflow-hidden rounded-xl bg-gradient-to-t px-4 py-2 text-gray-500 max-sm:hidden font-other">
|
19 |
<div class="flex items-center justify-start gap-2">
|
20 |
<img src={`https://huggingface.co/api/users/${space.author}/avatar`} class="w-3.5 h-3.5 rounded-full flex-none" alt={space.author} />
|
21 |
<div class="flex items-center justify-center gap-1">
|
22 |
+
<a href="https://huggingface.co/{space.author}" class="text-gray-500 hover:text-blue-600 font-other text-base" target="_blank">{space.author}</a>
|
23 |
+
<span class="text-gray-300 text-lg font-other">/</span>
|
24 |
+
<a href="https://huggingface.co/spaces/{space.id}" target="_blank" class="font-mono font-bold text-gray-800 hover:text-blue-600 font-namespace">{space.id?.split('/').pop()}</a>
|
25 |
</div>
|
26 |
</div>
|
27 |
<div class="inline-flex items-center overflow-hidden whitespace-nowrap rounded-md border bg-white text-sm leading-none text-gray-500 flex-none self-center "><button class="relative flex items-center overflow-hidden from-red-50 to-transparent dark:from-red-900 p-1 focus:outline-none" title="Unlike"><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32" fill="currentColor"><path d="M22.45,6a5.47,5.47,0,0,1,3.91,1.64,5.7,5.7,0,0,1,0,8L16,26.13,5.64,15.64a5.7,5.7,0,0,1,0-8,5.48,5.48,0,0,1,7.82,0L16,10.24l2.53-2.58A5.44,5.44,0,0,1,22.45,6m0-2a7.47,7.47,0,0,0-5.34,2.24L16,7.36,14.89,6.24a7.49,7.49,0,0,0-10.68,0,7.72,7.72,0,0,0,0,10.82L16,29,27.79,17.06a7.72,7.72,0,0,0,0-10.82A7.49,7.49,0,0,0,22.45,4Z"></path></svg> <svg class="absolute text-red-500 origin-center transform transition-transform ease-in
|
|
|
35 |
font-family: "IBM Plex Mono", sans-serif;
|
36 |
}
|
37 |
.font-other {
|
38 |
+
font-family: "Prout", sans-serif !important;
|
39 |
}
|
40 |
</style>
|
src/routes/api/models/+server.ts
CHANGED
@@ -81,6 +81,9 @@ export async function PATCH({ request } : RequestEvent) {
|
|
81 |
const hugging_face_request = await fetch(`https://huggingface.co/api/models?id=${model.id}&sort=likes7d`)
|
82 |
const hugging_face_model = await hugging_face_request.json()?.catch(() => {})
|
83 |
|
|
|
|
|
|
|
84 |
if (!hugging_face_model?.[0]) {
|
85 |
continue;
|
86 |
}
|
@@ -93,6 +96,7 @@ export async function PATCH({ request } : RequestEvent) {
|
|
93 |
downloads: hugging_face_model?.[0]?.downloads,
|
94 |
likes7d: hugging_face_model?.[0]?.trendingScore,
|
95 |
id: hugging_face_model?.[0]?.id,
|
|
|
96 |
}
|
97 |
})
|
98 |
.then(() => {
|
|
|
81 |
const hugging_face_request = await fetch(`https://huggingface.co/api/models?id=${model.id}&sort=likes7d`)
|
82 |
const hugging_face_model = await hugging_face_request.json()?.catch(() => {})
|
83 |
|
84 |
+
const hugging_face_request2 = await fetch(`https://huggingface.co/api/models/${model.id}`)
|
85 |
+
const hugging_face_model2 = await hugging_face_request2.json()?.catch(() => {})
|
86 |
+
|
87 |
if (!hugging_face_model?.[0]) {
|
88 |
continue;
|
89 |
}
|
|
|
96 |
downloads: hugging_face_model?.[0]?.downloads,
|
97 |
likes7d: hugging_face_model?.[0]?.trendingScore,
|
98 |
id: hugging_face_model?.[0]?.id,
|
99 |
+
instance_prompt: hugging_face_model2?.cardData?.instance_prompt,
|
100 |
}
|
101 |
})
|
102 |
.then(() => {
|
src/routes/generate/+page.svelte
CHANGED
@@ -21,7 +21,7 @@
|
|
21 |
|
22 |
let form = ((data?.model?.id && generation?.form?.model?.id && data?.model?.id !== generation?.form?.model?.id) || !generation?.form) ? {
|
23 |
model: data?.model ?? null,
|
24 |
-
inputs: ""
|
25 |
parameters: {
|
26 |
negative_prompt: ""
|
27 |
}
|
|
|
21 |
|
22 |
let form = ((data?.model?.id && generation?.form?.model?.id && data?.model?.id !== generation?.form?.model?.id) || !generation?.form) ? {
|
23 |
model: data?.model ?? null,
|
24 |
+
inputs: `${data?.model?.instance_prompt ?? ""}`,
|
25 |
parameters: {
|
26 |
negative_prompt: ""
|
27 |
}
|