Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 5,818 Bytes
e71d24a c479a59 332141a b0122ad 332141a 3b75cc4 e71d24a eb29a95 dd7ec11 e71d24a eb29a95 c479a59 d6da254 3b75cc4 d9ecfe6 97ec6f2 3b75cc4 d9ecfe6 3b75cc4 d9ecfe6 1f31a76 3b75cc4 e71d24a eb29a95 e71d24a 3b75cc4 c479a59 e71d24a eb29a95 3b75cc4 eb29a95 3b75cc4 a9314c8 549506b 332141a 3b75cc4 eb29a95 1f31a76 eb29a95 3b75cc4 a9314c8 332141a 549506b 332141a 3b75cc4 549506b eb29a95 549506b eb29a95 3b75cc4 a084673 3b75cc4 644d65a 9445ddf 52be592 e71d24a 1252a22 c79601a eb29a95 83deba1 eb29a95 1252a22 eb29a95 d9ecfe6 10926a7 d9ecfe6 eb29a95 4553d3e a1d7896 888a150 4553d3e a1d7896 4553d3e a1d7896 eb29a95 2c23da5 a1d7896 2c23da5 a1d7896 2c23da5 a1d7896 eb29a95 1f31a76 1252a22 1f31a76 1252a22 1f31a76 1252a22 1f31a76 e71d24a 7b25d55 8042cb9 2c23da5 eb29a95 332141a eb29a95 83deba1 eb29a95 a084673 2c23da5 eb29a95 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
<script lang="ts">
import { browser } from "$app/environment";
import InfiniteScroll from "svelte-infinite-scroll";
import { page } from "$app/stores";
import { onMount } from "svelte";
import { goto } from "$app/navigation";
import Button from "$lib/components/Button.svelte";
import Card from "$lib/components/models/Card.svelte";
import Input from "$lib/components/fields/Input.svelte";
import Radio from "$lib/components/fields/Radio.svelte";
import { MODELS_FILTER_OPTIONS } from "$lib/utils/index.js";
import GoTop from "$lib/components/GoTop.svelte";
import Drawer from "$lib/components/models/drawer/Drawer.svelte";
import type { ModelCard } from "$lib/type";
import { userStore } from "$lib/stores/use-user";
let data: {
models: ModelCard[],
total_items: number,
} = {
models: [],
total_items: 0,
}
let form: Record<string, string> = {
filter: $page.url.searchParams.get('filter') ?? "hotest",
search: $page.url.searchParams.get('search') ?? "",
base_model: $page.url.searchParams.get('base_model') ?? "",
page: "0"
}
let submitModelDialog = false;
onMount(() => {
refetch(false);
});
$: elementScroll = browser ? document?.getElementById('app') : undefined;
const handleFetchMore = async () => {
form.page = (Number(form.page) + 1).toString();
refetch(true);
}
const handleChangeFilter = async (filter: string) => {
form.filter = filter;
form.page = "0";
$page.url.searchParams.set('filter', filter);
await goto(`?${$page.url.searchParams.toString()}`);
refetch(false);
}
const handleChangeBaseModel = async (event: any) => {
const base_model = event.target.value
form.base_model = base_model;
$page.url.searchParams.set('base_model', base_model);
await goto(`?${$page.url.searchParams.toString()}`);
refetch(false);
}
let timeout: any;
const handleChangeSearch = async (search: string) => {
clearTimeout(timeout);
form.search = search;
form.page = "0";
timeout = setTimeout(async () => {
if (search === "") $page.url.searchParams.delete('search');
else $page.url.searchParams.set('search', search);
await goto(`?${$page.url.searchParams.toString()}`);
refetch(false);
}, 500);
}
const refetch = async (add: boolean) => {
const request = await fetch(`/api/models?${new URLSearchParams({...form })}`);
const response = await request.json();
if (add) data.models = [...data.models, ...response.cards] as any[];
else {
data.models = response.cards;
data.total_items = response.total_items;
}
}
</script>
<main class="px-6 py-10 lg:px-10 lg:py-12 relative">
<Drawer onSearch={handleChangeSearch} />
<h1 class="text-white font-semibold text-2xl">
Explore Models ({data?.total_items ?? 0})
</h1>
<div class="bg-cyan-500/20 max-w-xl border-2 border-cyan-500/30 w-full p-3 text-white rounded-lg mt-4">
<p class="font-semibold">FLUX LoRAs are here! β¨</p>
<p class="opacity-70 text-sm">
We are excited to announce the arrival of the first FLUX models on LoRA Studio.
</p>
</div>
<div class="flex items-start sm:items-center justify-between mt-5 flex-col sm:flex-row gap-5 sm:justify-between">
<Radio
options={[
...MODELS_FILTER_OPTIONS,
...($userStore?.is_admin ? [
{
label: "Staff only",
value: "staff_only",
icon: "lets-icons:view-hide-fill",
iconColor: "text-yellow-500"
}
] : [])
]}
value="{form.filter}"
onChange={handleChangeFilter}
/>
<div class="items-center justify-end gap-5 hidden lg:flex">
<Button href="https://huggingface.co/new/stable-diffusion-lora" target="_blank" icon="ic:round-plus" theme="dark" size="lg">Upload</Button>
<Button
icon="octicon:upload-16"
theme="blue"
target="_blank"
href="https://huggingface.co/spaces/multimodalart/civitai-to-hf"
size="lg"
>
Migrate
</Button>
</div>
<div class="items-center justify-end gap-3 flex lg:hidden">
<Button href="https://huggingface.co/new/stable-diffusion-lora" target="_blank" icon="ic:round-plus" theme="dark" size="md">Create</Button>
<Button
icon="octicon:upload-16"
theme="blue"
target="_blank"
href="https://huggingface.co/spaces/multimodalart/civitai-to-hf"
size="md"
>
Migrate
</Button>
</div>
</div>
<div class="mt-5 max-w-sm flex items-center justify-start gap-5 w-full">
<Input value={form.search} className="lg:min-w-[300px]" placeholder="Filter by model name" onChange={handleChangeSearch} />
<div class="flex flex-col items-start justify-center gap-1.5">
<p class="text-xs text-white/60 whitespace-nowrap flex items-center justify-start gap-2">
Filter by
<span class="relative">
<span class="w-2 h-2 rounded-full block bg-cyan-500"></span>
<span class="w-2 h-2 rounded-full block bg-cyan-500 animate-ping absolute top-0 left-0"></span>
</span>
</p>
<select value={form.base_model} class="text-white bg-transparent outline-none cursor-pointer" on:change={handleChangeBaseModel}>
<option value="">
All models
</option>
<option value="flux">
Flux
</option>
<option value="sd3">
Stable Diffusion 3
</option>
<option value="sdxl">
Stable Diffusion XL
</option>
<option value="sd1">
Stable Diffusion 1
</option>
</select>
</div>
</div>
<div class="mx-auto grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 2xl:grid-cols-4 gap-5 mt-8 lg:mt-10">
{#each data.models as card (card.id)}
<Card card={card} />
{/each}
{#if data.models.length === 0}
<p class="text-neutral-400 text-left w-full">No models found</p>
{/if}
<InfiniteScroll
elementScroll="{elementScroll ?? undefined}"
threshold={100}
hasMore={data.total_items > data.models.length}
on:loadMore={handleFetchMore}
/>
<GoTop />
</div>
<slot />
</main> |