filter options
Browse files- index.html +68 -23
index.html
CHANGED
@@ -4,16 +4,16 @@
|
|
4 |
<head>
|
5 |
<meta charset="utf-8" />
|
6 |
<meta name="viewport" content="width=device-width" />
|
7 |
-
|
8 |
<title>Diffusers gallery</title>
|
9 |
<meta name="description" content="Discover all difussion models on the Hugging Face hub.">
|
10 |
-
|
11 |
<meta property="og:url" content="https://huggingface-projects-diffusers-gallery.hf.space/">
|
12 |
<meta property="og:type" content="website">
|
13 |
<meta property="og:title" content="Hugging Face - Diffusers Models Gallery">
|
14 |
<meta property="og:description" content="Discover all difussion models on the Hugging Face hub.">
|
15 |
<meta property="og:image" content="https://huggingface-projects-diffusers-gallery.hf.space/Fo6vR6JX0AEjbw1.jpeg">
|
16 |
-
|
17 |
<meta name="twitter:card" content="player">
|
18 |
<meta property="twitter:url" content="https://huggingface-projects-diffusers-gallery.hf.space/">
|
19 |
<meta name="twitter:description" content="Discover all difussion models on the Hugging Face hub.">
|
@@ -23,18 +23,19 @@
|
|
23 |
|
24 |
<meta name="twitter:image" content="https://huggingface-projects-diffusers-gallery.hf.space/Fo6vR6JX0AEjbw1.jpeg" />
|
25 |
<meta name="twitter:player" content="https://huggingface-projects-diffusers-gallery.hf.space/index.html" />
|
26 |
-
<meta name="twitter:player:width" content="100%"/>
|
27 |
-
<meta name="twitter:player:height" content="600"/>
|
28 |
-
|
29 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.1/iframeResizer.contentWindow.min.js"></script>
|
30 |
<script src="https://cdn.tailwindcss.com"></script>
|
31 |
<style>
|
32 |
-
body,
|
|
|
33 |
height: 100%;
|
34 |
}
|
35 |
</style>
|
36 |
|
37 |
-
|
38 |
<script src="https://cdn.tailwindcss.com"></script>
|
39 |
|
40 |
<script type="module">
|
@@ -44,7 +45,7 @@
|
|
44 |
|
45 |
Alpine.data("modelsData", () => ({
|
46 |
async init() {
|
47 |
-
const data = await this.getModels(this.page);
|
48 |
this.models = data.models.map((model) => ({
|
49 |
id: model.id,
|
50 |
likes: model.likes,
|
@@ -66,6 +67,7 @@
|
|
66 |
ASSETS_URL: "https://d26smi9133w0oo.cloudfront.net/diffusers-gallery/",
|
67 |
models: [],
|
68 |
filter: "all",
|
|
|
69 |
page: 1,
|
70 |
totalPages: -1,
|
71 |
isNSFW(model) {
|
@@ -80,15 +82,14 @@
|
|
80 |
}
|
81 |
return ""
|
82 |
},
|
83 |
-
buttonClass(filter) {
|
84 |
-
if (this
|
85 |
return "bg-black shadow-lg text-white"
|
86 |
}
|
87 |
return "text-gray-600 hover:bg-gray-200 hover:text-gray-800"
|
88 |
},
|
89 |
filterModels() {
|
90 |
-
|
91 |
-
switch(this.filter) {
|
92 |
case "all":
|
93 |
return this.models
|
94 |
case "anime":
|
@@ -100,16 +101,30 @@
|
|
100 |
}
|
101 |
return []
|
102 |
},
|
103 |
-
|
104 |
-
|
105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
(res) => res.json()
|
107 |
);
|
108 |
},
|
109 |
nextPage() {
|
110 |
if (this.page < this.totalPages) {
|
111 |
this.page += 1;
|
112 |
-
this.getModels(this.page).then((data) => {
|
113 |
const models = data.models.map((model) => ({
|
114 |
id: model.id,
|
115 |
likes: model.likes,
|
@@ -126,14 +141,44 @@
|
|
126 |
</head>
|
127 |
|
128 |
<body class="pb-10 pt-5 bg-gray-100 relative">
|
129 |
-
<section class="container px-6 grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4 mx-auto relative"
|
130 |
-
|
|
|
131 |
<h1 class="mr-auto text-lg font-semibold">Diffusers Models Gallery</h1>
|
132 |
-
<button :class="buttonClass('all')" class="px-4 py-1 rounded-full" @click="filter='all'">All</button>
|
133 |
-
<button :class="buttonClass('anime')" class="text-gray-600 hover:bg-gray-200 hover:text-gray-800 px-4 py-1 rounded-full" @click="filter='anime'">Anime</button>
|
134 |
-
<button :class="buttonClass('3d')" class="text-gray-600 hover:bg-gray-200 hover:text-gray-800 px-4 py-1 rounded-full" @click="filter='3d'">3D</button>
|
135 |
-
<button :class="buttonClass('realistic')" class="text-gray-600 hover:bg-gray-200 hover:text-gray-800 px-4 py-1 rounded-full" @click="filter='realistic'">Realistic</button>
|
136 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
<template x-for="model in filterModels" :key="model.id">
|
138 |
<template x-if="model.images.length > 0">
|
139 |
<a :href="`https://huggingface.co/${model.id}`"
|
|
|
4 |
<head>
|
5 |
<meta charset="utf-8" />
|
6 |
<meta name="viewport" content="width=device-width" />
|
7 |
+
|
8 |
<title>Diffusers gallery</title>
|
9 |
<meta name="description" content="Discover all difussion models on the Hugging Face hub.">
|
10 |
+
|
11 |
<meta property="og:url" content="https://huggingface-projects-diffusers-gallery.hf.space/">
|
12 |
<meta property="og:type" content="website">
|
13 |
<meta property="og:title" content="Hugging Face - Diffusers Models Gallery">
|
14 |
<meta property="og:description" content="Discover all difussion models on the Hugging Face hub.">
|
15 |
<meta property="og:image" content="https://huggingface-projects-diffusers-gallery.hf.space/Fo6vR6JX0AEjbw1.jpeg">
|
16 |
+
|
17 |
<meta name="twitter:card" content="player">
|
18 |
<meta property="twitter:url" content="https://huggingface-projects-diffusers-gallery.hf.space/">
|
19 |
<meta name="twitter:description" content="Discover all difussion models on the Hugging Face hub.">
|
|
|
23 |
|
24 |
<meta name="twitter:image" content="https://huggingface-projects-diffusers-gallery.hf.space/Fo6vR6JX0AEjbw1.jpeg" />
|
25 |
<meta name="twitter:player" content="https://huggingface-projects-diffusers-gallery.hf.space/index.html" />
|
26 |
+
<meta name="twitter:player:width" content="100%" />
|
27 |
+
<meta name="twitter:player:height" content="600" />
|
28 |
+
|
29 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.1/iframeResizer.contentWindow.min.js"></script>
|
30 |
<script src="https://cdn.tailwindcss.com"></script>
|
31 |
<style>
|
32 |
+
body,
|
33 |
+
html {
|
34 |
height: 100%;
|
35 |
}
|
36 |
</style>
|
37 |
|
38 |
+
|
39 |
<script src="https://cdn.tailwindcss.com"></script>
|
40 |
|
41 |
<script type="module">
|
|
|
45 |
|
46 |
Alpine.data("modelsData", () => ({
|
47 |
async init() {
|
48 |
+
const data = await this.getModels(this.page, this.sort);
|
49 |
this.models = data.models.map((model) => ({
|
50 |
id: model.id,
|
51 |
likes: model.likes,
|
|
|
67 |
ASSETS_URL: "https://d26smi9133w0oo.cloudfront.net/diffusers-gallery/",
|
68 |
models: [],
|
69 |
filter: "all",
|
70 |
+
sort: "trending",
|
71 |
page: 1,
|
72 |
totalPages: -1,
|
73 |
isNSFW(model) {
|
|
|
82 |
}
|
83 |
return ""
|
84 |
},
|
85 |
+
buttonClass(attr, filter) {
|
86 |
+
if (this[attr] === filter) {
|
87 |
return "bg-black shadow-lg text-white"
|
88 |
}
|
89 |
return "text-gray-600 hover:bg-gray-200 hover:text-gray-800"
|
90 |
},
|
91 |
filterModels() {
|
92 |
+
switch (this.filter) {
|
|
|
93 |
case "all":
|
94 |
return this.models
|
95 |
case "anime":
|
|
|
101 |
}
|
102 |
return []
|
103 |
},
|
104 |
+
sortModels(sort) {
|
105 |
+
this.sort = sort
|
106 |
+
this.page = 1
|
107 |
+
this.getModels(this.page, this.sort).then((data) => {
|
108 |
+
const models = data.models.map((model) => ({
|
109 |
+
id: model.id,
|
110 |
+
likes: model.likes,
|
111 |
+
class: model.class,
|
112 |
+
images: model.images.filter((image) => image && image.endsWith(".jpg")),
|
113 |
+
}));
|
114 |
+
this.models = models;
|
115 |
+
});
|
116 |
+
|
117 |
+
},
|
118 |
+
getModels(page, sort) {
|
119 |
+
// return fetch(`http://localhost:8000/api/models?page=${page}&sort=${sort}`).then(
|
120 |
+
return fetch(`https://huggingface-projects-diffusers-gallery-bot.hf.space/api/models?page=${page}`).then(
|
121 |
(res) => res.json()
|
122 |
);
|
123 |
},
|
124 |
nextPage() {
|
125 |
if (this.page < this.totalPages) {
|
126 |
this.page += 1;
|
127 |
+
this.getModels(this.page, this.sort).then((data) => {
|
128 |
const models = data.models.map((model) => ({
|
129 |
id: model.id,
|
130 |
likes: model.likes,
|
|
|
141 |
</head>
|
142 |
|
143 |
<body class="pb-10 pt-5 bg-gray-100 relative">
|
144 |
+
<section class="container px-6 grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4 mx-auto relative"
|
145 |
+
x-data="modelsData">
|
146 |
+
<div class="col-span-2 md:col-span-1 flex items-center gap-2 row-start-1">
|
147 |
<h1 class="mr-auto text-lg font-semibold">Diffusers Models Gallery</h1>
|
|
|
|
|
|
|
|
|
148 |
</div>
|
149 |
+
|
150 |
+
<div class="col-span-2 md:col-span-3 flex items-center gap-2 flex flex-wrap lg-auto">
|
151 |
+
<div class="flex text-xs gap-2">
|
152 |
+
<span class="px-3 py-1 font-thin">sort by</span>
|
153 |
+
<button :class="buttonClass('sort', 'trending')" class="px-2 md:px-3 py-1 rounded-full text"
|
154 |
+
@click="sortModels('trending')">Trending</button>
|
155 |
+
<button :class="buttonClass('sort', 'recent')"
|
156 |
+
class="text-gray-600 hover:bg-gray-200 hover:text-gray-800 px-2 md:px-3 py-1 rounded-full"
|
157 |
+
@click="sortModels('recent')">Recent</button>
|
158 |
+
<button :class="buttonClass('sort', 'likes')"
|
159 |
+
class="text-gray-600 hover:bg-gray-200 hover:text-gray-800 px-2 md:px-3 py-1 rounded-full"
|
160 |
+
@click="sortModels('likes')">Most
|
161 |
+
Likes</button>
|
162 |
+
</div>
|
163 |
+
<div class="flex text-xs gap-2">
|
164 |
+
<span class="px-2 md:px-3 py-1 font-thin"> style</span>
|
165 |
+
<button :class="buttonClass('filter', 'all')" class="px-2 md:px-3 py-1 rounded-full"
|
166 |
+
@click="filter='all'">All</button>
|
167 |
+
<button :class="buttonClass('filter', 'anime')"
|
168 |
+
class="text-gray-600 hover:bg-gray-200 hover:text-gray-800 px-2 md:px-3 py-1 rounded-full"
|
169 |
+
@click="filter='anime'">Anime</button>
|
170 |
+
<button :class="buttonClass('filter', '3d')"
|
171 |
+
class="text-gray-600 hover:bg-gray-200 hover:text-gray-800 px-2 md:px-3 py-1 rounded-full"
|
172 |
+
@click="filter='3d'">3D</button>
|
173 |
+
<button :class="buttonClass('filter', 'realistic')"
|
174 |
+
class="text-gray-600 hover:bg-gray-200 hover:text-gray-800 px-2 md:px-3 py-1 rounded-full"
|
175 |
+
@click="filter='realistic'">Realistic</button>
|
176 |
+
<button :class="buttonClass('filter', 'realistic')"
|
177 |
+
class="text-gray-600 hover:bg-gray-200 hover:text-gray-800 px-2 md:px-3 py-1 rounded-full"
|
178 |
+
@click="filter='realistic'">18+</button>
|
179 |
+
</div>
|
180 |
+
</div>
|
181 |
+
|
182 |
<template x-for="model in filterModels" :key="model.id">
|
183 |
<template x-if="model.images.length > 0">
|
184 |
<a :href="`https://huggingface.co/${model.id}`"
|