radames commited on
Commit
d77412f
1 Parent(s): b239782

add classification data

Browse files
Files changed (1) hide show
  1. index.html +108 -103
index.html CHANGED
@@ -1,114 +1,119 @@
1
  <!DOCTYPE html>
2
  <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>Diffusers gallery</title>
7
- <script src="https://cdn.tailwindcss.com"></script>
8
- <script src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.1/iframeResizer.contentWindow.min.js"></script>
9
 
10
- <script type="module">
11
- import Alpine from "https://cdn.skypack.dev/alpinejs";
12
- import Intersect from "https://cdn.skypack.dev/@alpinejs/intersect";
13
- Alpine.plugin(Intersect);
 
 
14
 
15
- Alpine.data("modelsData", () => ({
16
- async init() {
17
- const data = await this.getModels(this.page);
18
- this.models = data.models.map((model) => ({
19
- id: model.id,
20
- likes: model.likes,
21
- images: model.images.filter((image) => image && image.endsWith(".jpg")),
22
- }));
23
 
24
- this.totalPages = data.totalPages;
25
- },
26
- ASSETS_URL: "https://d26smi9133w0oo.cloudfront.net/diffusers-gallery/",
27
- models: [],
28
- page: 1,
29
- totalPages: -1,
30
- getModels(page) {
31
- // return fetch(`http://localhost:8000/api/models?page=${page}`)
32
- return fetch(`https://huggingface-projects-diffusers-gallery-bot.hf.space/api/models?page=${page}`).then(
33
- (res) => res.json()
34
- );
35
- },
36
- nextPage() {
37
- if (this.page < this.totalPages) {
38
- this.page += 1;
39
- this.getModels(this.page).then((data) => {
40
- const models = data.models.map((model) => ({
41
- id: model.id,
42
- likes: model.likes,
43
- images: model.images.filter((image) => image && image.endsWith(".jpg")),
44
- }));
45
- this.models = this.models.concat(models);
46
- });
 
 
 
 
 
 
 
 
 
 
47
  }
48
- },
49
- }));
50
- Alpine.start();
51
- </script>
52
- </head>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
 
54
- <body class="pb-10 pt-5 bg-gray-100">
55
- <section class="container px-6 grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4 mx-auto" x-data="modelsData">
56
- <div class="col-span-2 md:col-span-3 lg:col-span-4 flex items-center gap-2">
57
- <h1 class="mr-auto text-lg font-semibold">Diffusers Models Gallery</h1>
58
- <button class="bg-black shadow-lg px-4 py-1 rounded-full text-white">All</button>
59
- <!-- <button class="text-gray-600 px-4 py-1 rounded-full hover:bg-gray-200 hover:text-gray-800">Anime</button>
60
  <button class="text-gray-600 px-4 py-1 rounded-full hover:bg-gray-200 hover:text-gray-800">3D</button>
61
  <button class="text-gray-600 px-4 py-1 rounded-full hover:bg-gray-200 hover:text-gray-800">Realistic</button> -->
62
- </div>
63
- <template x-for="model in models" :key="model.id">
64
- <template x-if="model.images.length > 0">
65
- <a
66
- :href="`https://huggingface.co/${model.id}`"
67
- class="block bg-gray-900 rounded-xl overflow-hidden relative group aspect-square text-white"
68
- target="_blank"
69
- >
70
- <div
71
- class="absolute bottom-0 p-4 bg-gradient-to-t text-white pt-10 from-black/90 via-black/70 to-transparent w-full z-10"
72
- >
73
- <div class="text-sm flex items-center group-hover:translate-x-0.5 transition">
74
- <svg
75
- class="mr-1.5 text-white/70"
76
- xmlns="http://www.w3.org/2000/svg"
77
- xmlns:xlink="http://www.w3.org/1999/xlink"
78
- aria-hidden="true"
79
- focusable="false"
80
- role="img"
81
- width="1em"
82
- height="1em"
83
- preserveAspectRatio="xMidYMid meet"
84
- viewBox="0 0 32 32"
85
- fill="currentColor"
86
- >
87
- <path
88
- d="M22.5,4c-2,0-3.9,0.8-5.3,2.2L16,7.4l-1.1-1.1C12,3.3,7.2,3.3,4.3,6.2c0,0-0.1,0.1-0.1,0.1c-3,3-3,7.8,0,10.8L16,29l11.8-11.9c3-3,3-7.8,0-10.8C26.4,4.8,24.5,4,22.5,4z"
89
- ></path>
90
- </svg>
91
- <span x-text="model.likes"></span>
92
- </div>
93
- <div
94
- x-text="model.id"
95
- class="text-base md:text-lg lg:text-xl font-semibold group-hover:translate-x-0.5 transition"
96
- ></div>
97
  </div>
98
- <div class="group-hover:brightness-90 h-full">
99
- <template x-if="model.images[0]">
100
- <img
101
- :src="()=> ASSETS_URL + model.images[0]"
102
- :alt="model.id"
103
- alt=""
104
- class="w-full h-full object-cover group-hover:scale-[1.01] transition"
105
- />
106
- </template>
107
- </div>
108
- </a>
109
- </template>
110
  </template>
111
- <div class="h-12" x-intersect="nextPage"></div>
112
- </section>
113
- </body>
114
- </html>
 
 
 
1
  <!DOCTYPE html>
2
  <html>
 
 
 
 
 
 
3
 
4
+ <head>
5
+ <meta charset="utf-8" />
6
+ <meta name="viewport" content="width=device-width" />
7
+ <title>Diffusers gallery</title>
8
+ <script src="https://cdn.tailwindcss.com"></script>
9
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.1/iframeResizer.contentWindow.min.js"></script>
10
 
11
+ <script type="module">
12
+ import Alpine from "https://cdn.skypack.dev/alpinejs";
13
+ import Intersect from "https://cdn.skypack.dev/@alpinejs/intersect";
14
+ Alpine.plugin(Intersect);
 
 
 
 
15
 
16
+ Alpine.data("modelsData", () => ({
17
+ async init() {
18
+ const data = await this.getModels(this.page);
19
+ this.models = data.models.map((model) => ({
20
+ id: model.id,
21
+ likes: model.likes,
22
+ class: model.class,
23
+ //"anime"
24
+ //"3d"
25
+ //"other"
26
+ //"real_life"
27
+ //"manga_like"
28
+ //"aesthetic"
29
+ //"not_aesthetic"
30
+ //"safe"
31
+ //"suggestive"
32
+ //"explicit"
33
+ images: model.images.filter((image) => image && image.endsWith(".jpg")),
34
+ }));
35
+ this.totalPages = data.totalPages;
36
+ },
37
+ ASSETS_URL: "https://d26smi9133w0oo.cloudfront.net/diffusers-gallery/",
38
+ models: [],
39
+ page: 1,
40
+ totalPages: -1,
41
+ isNSFW(model) {
42
+ if ("class" in model) {
43
+ // check if class is empty object
44
+ if (Object.keys(model.class).length === 0) {
45
+ return ""
46
+ }
47
+ if (model.class.explicit > 0.1 || model.class.suggestive > 0.4) {
48
+ return "blur-md"
49
  }
50
+ }
51
+ return ""
52
+ },
53
+ getModels(page) {
54
+ // return fetch(`http://localhost:8000/api/models?page=${page}`).then(
55
+ return fetch(`https://huggingface-projects-diffusers-gallery-bot.hf.space/api/models?page=${page}`).then(
56
+ (res) => res.json()
57
+ );
58
+ },
59
+ nextPage() {
60
+ if (this.page < this.totalPages) {
61
+ this.page += 1;
62
+ this.getModels(this.page).then((data) => {
63
+ const models = data.models.map((model) => ({
64
+ id: model.id,
65
+ likes: model.likes,
66
+ class: model.class,
67
+ images: model.images.filter((image) => image && image.endsWith(".jpg")),
68
+ }));
69
+ this.models = this.models.concat(models);
70
+ });
71
+ }
72
+ },
73
+ }));
74
+ Alpine.start();
75
+ </script>
76
+ </head>
77
 
78
+ <body class="pb-10 pt-5 bg-gray-100">
79
+ <section class="container px-6 grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4 mx-auto" x-data="modelsData">
80
+ <div class="col-span-2 md:col-span-3 lg:col-span-4 flex items-center gap-2">
81
+ <h1 class="mr-auto text-lg font-semibold">Diffusers Models Gallery</h1>
82
+ <button class="bg-black shadow-lg px-4 py-1 rounded-full text-white">All</button>
83
+ <!-- <button class="text-gray-600 px-4 py-1 rounded-full hover:bg-gray-200 hover:text-gray-800">Anime</button>
84
  <button class="text-gray-600 px-4 py-1 rounded-full hover:bg-gray-200 hover:text-gray-800">3D</button>
85
  <button class="text-gray-600 px-4 py-1 rounded-full hover:bg-gray-200 hover:text-gray-800">Realistic</button> -->
86
+ </div>
87
+ <template x-for="model in models" :key="model.id">
88
+ <template x-if="model.images.length > 0">
89
+ <a :href="`https://huggingface.co/${model.id}`"
90
+ class="block bg-gray-900 rounded-xl overflow-hidden relative group aspect-square text-white" target="_blank">
91
+ <div
92
+ class="absolute bottom-0 p-4 bg-gradient-to-t text-white pt-10 from-black/90 via-black/70 to-transparent w-full z-10">
93
+ <div class="text-sm flex items-center group-hover:translate-x-0.5 transition">
94
+ <svg class="mr-1.5 text-white/70" xmlns="http://www.w3.org/2000/svg"
95
+ xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" focusable="false" role="img" width="1em"
96
+ height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32" fill="currentColor">
97
+ <path
98
+ d="M22.5,4c-2,0-3.9,0.8-5.3,2.2L16,7.4l-1.1-1.1C12,3.3,7.2,3.3,4.3,6.2c0,0-0.1,0.1-0.1,0.1c-3,3-3,7.8,0,10.8L16,29l11.8-11.9c3-3,3-7.8,0-10.8C26.4,4.8,24.5,4,22.5,4z">
99
+ </path>
100
+ </svg>
101
+ <span x-text="model.likes"></span>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  </div>
103
+ <div x-text="model.id"
104
+ class="text-base md:text-lg lg:text-xl font-semibold group-hover:translate-x-0.5 transition"></div>
105
+ </div>
106
+ <div class="group-hover:brightness-90 h-full" :class="isNSFW(model)">
107
+ <template x-if="model.images[0]">
108
+ <img :src="()=> ASSETS_URL + model.images[0]" :alt="model.id" alt=""
109
+ class="w-full h-full object-cover group-hover:scale-[1.01] transition" />
110
+ </template>
111
+ </div>
112
+ </a>
 
 
113
  </template>
114
+ </template>
115
+ <div class="h-12" x-intersect="nextPage"></div>
116
+ </section>
117
+ </body>
118
+
119
+ </html>