malcolmrey commited on
Commit
5399051
·
verified ·
1 Parent(s): f4a00c8

Upload 5 files

Browse files
Files changed (5) hide show
  1. comparator.js +200 -0
  2. data-civitai.js +0 -0
  3. data-local.js +0 -0
  4. index.html +239 -19
  5. unknown.jpg +0 -0
comparator.js ADDED
@@ -0,0 +1,200 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const unknownImage =
2
+ 'https://mohitpawar.com/wp-content/uploads/2010/10/unknown.jpg';
3
+
4
+ function handleKnownKeyExceptions(key) {
5
+ switch (key) {
6
+ case 'danika"cbg19"leemassey':
7
+ return 'cbg';
8
+ case 'joannarudaxsh':
9
+ return 'rudaxsh';
10
+ case 'cyberpunk2077:v':
11
+ return 'v';
12
+ case 'character:danascully':
13
+ return 'gilliananderson';
14
+ default:
15
+ return key;
16
+ }
17
+ }
18
+
19
+ function isKnownSkippableKey(key) {
20
+ if (key.startsWith('concept:')
21
+ || key.startsWith('style:')
22
+ || key.startsWith('clothing:')) {
23
+ return true;
24
+ }
25
+
26
+ switch (key) {
27
+ case "sdxl0.9betatests:famouspeople":
28
+ return true;
29
+ default:
30
+ return false;
31
+ }
32
+ }
33
+
34
+ function prepareKey(name) {
35
+ return handleKnownKeyExceptions(
36
+ name
37
+ .toLowerCase()
38
+ .replaceAll(' ', '')
39
+ .replaceAll('-', '')
40
+ .replaceAll("'", '')
41
+ .replaceAll('ł', 'l')
42
+ .normalize('NFD')
43
+ .replace(/\p{Diacritic}/gu, ''),
44
+ );
45
+ }
46
+
47
+ function setImageUrl(key, imageUrl) {
48
+ if (!presence[key].imageUrl) {
49
+ presence[key].imageUrl = imageUrl;
50
+ }
51
+ }
52
+
53
+ function clearCurrentSearchValue() {
54
+ document.getElementById('search').value = '';
55
+ }
56
+
57
+ function getCurrentSearchValue() {
58
+ return document.getElementById('search').value;
59
+ }
60
+
61
+ function getCurrentSearchMode() {
62
+ return document.getElementById('searchMode').value;
63
+ }
64
+
65
+ function escapeHtml(unsafe) {
66
+ return unsafe
67
+ .replace(/&/g, '&')
68
+ .replace(/</g, '&lt;')
69
+ .replace(/>/g, '&gt;')
70
+ .replace(/"/g, '&quot;')
71
+ .replace(/'/g, '&#039;');
72
+ }
73
+
74
+ function formatNumber(num) {
75
+ return Math.abs(num) > 999
76
+ ? `${Math.sign(num) * (Math.abs(num) / 1000).toFixed(1)}k`
77
+ : Math.sign(num) * Math.abs(num);
78
+ }
79
+
80
+ function compare(a, b) {
81
+ if (a.name < b.name) {
82
+ return -1;
83
+ }
84
+ if (a.name > b.name) {
85
+ return 1;
86
+ }
87
+ return 0;
88
+ }
89
+
90
+ function linkPrefix(url) {
91
+ if (!url) return '';
92
+
93
+ return `<a href='${url}' target='_blank'>`;
94
+ }
95
+
96
+ function linkSuffix(url) {
97
+ if (!url) return '';
98
+ return '</a>';
99
+ }
100
+
101
+ function filterByType(element) {
102
+ switch (getCurrentSearchMode()) {
103
+ case 'available':
104
+ if (document.getElementById('selectedLocon').checked && !element.locon) {
105
+ return false;
106
+ }
107
+
108
+ if (document.getElementById('selectedLora').checked && !element.lora) {
109
+ return false;
110
+ }
111
+
112
+ if (
113
+ document.getElementById('selectedEmbedding').checked &&
114
+ !element.embedding
115
+ ) {
116
+ return false;
117
+ }
118
+
119
+ if (document.getElementById('selectedFlux').checked && !element.flux) {
120
+ return false;
121
+ }
122
+ break;
123
+ case 'missing': {
124
+ if (document.getElementById('selectedLocon').checked && element.locon) {
125
+ return false;
126
+ }
127
+
128
+ if (document.getElementById('selectedLora').checked && element.lora) {
129
+ return false;
130
+ }
131
+
132
+ if (
133
+ document.getElementById('selectedEmbedding').checked &&
134
+ element.embedding
135
+ ) {
136
+ return false;
137
+ }
138
+
139
+ if (document.getElementById('selectedFlux').checked && element.flux) {
140
+ return false;
141
+ }
142
+ break;
143
+ }
144
+ }
145
+
146
+ return true;
147
+ }
148
+
149
+ function searchModels(value) {
150
+ const lowerCaseValue = value.toLowerCase();
151
+
152
+ const filtered = presenceModels.filter((element) => {
153
+ return (
154
+ (element.key.toLowerCase().includes(lowerCaseValue) || value === '*') &&
155
+ filterByType(element)
156
+ );
157
+ });
158
+
159
+ document.getElementById('found').value = filtered.length;
160
+
161
+ let htmlContent = '';
162
+ const contentDiv = document.getElementById('mainContent');
163
+
164
+ let keys = [];
165
+ filtered.forEach((element) => {
166
+ keys.push(element.key);
167
+ htmlContent += `<div class="element">
168
+ <div class="modelName" title="${escapeHtml(element.key)}">${
169
+ element.key
170
+ }</div>
171
+
172
+ <div><img src='${
173
+ element.imageUrl ?? unknownImage
174
+ }' height="264" width="192"'/>
175
+ </div>
176
+
177
+ <div class="statsBox">
178
+ Locon: ${yesNo(element.locon)}
179
+ ${linkPrefix(element.loconHFLink)} HF: ${yesNo(
180
+ element.loconHF,
181
+ )}${linkSuffix(element.loconHFLink)}<br>
182
+ Lora:&nbsp;${yesNo(element.lora)}
183
+ ${linkPrefix(element.loraHFLink)}HF: ${yesNo(
184
+ element.loraHF,
185
+ )}${linkSuffix(element.loraHFLink)}
186
+ Embedding: ${yesNo(element.embedding)}
187
+ ${linkPrefix(element.embeddingHFLink)}HF: ${yesNo(
188
+ element.embeddingHF,
189
+ )}${linkSuffix(element.embeddingHFLink)}
190
+ Flux: ${yesNo(element.flux)} ${linkPrefix(element.fluxHFLink)}HF: ${yesNo(
191
+ element.fluxHF,
192
+ )}${linkSuffix(element.fluxHFLink)}
193
+ </div>
194
+ </div>`;
195
+ });
196
+
197
+ console.log('keys', keys);
198
+
199
+ contentDiv.innerHTML = htmlContent;
200
+ }
data-civitai.js ADDED
The diff for this file is too large to render. See raw diff
 
data-local.js ADDED
The diff for this file is too large to render. See raw diff
 
index.html CHANGED
@@ -1,19 +1,239 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <script type="text/javascript" src="data-civitai.js"></script>
6
+ <script type="text/javascript" src="data-local.js"></script>
7
+ <script type="text/javascript" src="comparator.js"></script>
8
+ <style>
9
+ body {
10
+ color: whitesmoke;
11
+ background-color: rgb(13, 46, 11);
12
+ }
13
+
14
+ a {
15
+ text-decoration: none;
16
+ color: white;
17
+ }
18
+
19
+ .mainContent {
20
+ position: absolute;
21
+ margin-top: 20px;
22
+ display: flex;
23
+ justify-content: center;
24
+ flex-wrap: wrap;
25
+ }
26
+
27
+ .searchBox {
28
+ margin-top: 15px;
29
+ margin-left: 20px;
30
+ }
31
+
32
+ .found {
33
+ width: 30px;
34
+ }
35
+
36
+ .element {
37
+ padding: 0;
38
+ margin: 3px;
39
+ border: 1px solid rgb(5, 90, 0);
40
+ display: inline-block;
41
+ position: relative;
42
+ width: 192px;
43
+ height: 283px;
44
+ }
45
+
46
+ .element .modelType {
47
+ position: absolute;
48
+ padding: 2px;
49
+ padding-left: 4px;
50
+ padding-right: 4px;
51
+ right: 0;
52
+ background-color: rgba(0, 0, 0, 0.5);
53
+ bottom: 22px;
54
+ }
55
+
56
+ .element .modelName {
57
+ background-color: rgba(50, 217, 8, 0.15);
58
+ text-overflow: ellipsis;
59
+ overflow: hidden;
60
+ white-space: nowrap;
61
+ padding-left: 2px;
62
+ }
63
+
64
+ .element .modelCreator {
65
+ position: absolute;
66
+ background-color: rgba(0, 0, 0, 0.5);
67
+ padding: 2px;
68
+ padding-left: 4px;
69
+ padding-right: 4px;
70
+ bottom: 22px;
71
+ }
72
+
73
+ .statsBox {
74
+ position: relative;
75
+ top: -88px;
76
+ padding-left: 6px;
77
+ background-color: rgba(0, 0, 0, 0.5);
78
+ }
79
+
80
+ .statsBox .statsDownloadCount {
81
+ position: absolute;
82
+ top: 0;
83
+ left: 0;
84
+ }
85
+
86
+ .statsBox .statsFavoriteCount {
87
+ position: absolute;
88
+ top: 0;
89
+ left: 52px;
90
+ }
91
+
92
+ .statsBox .statsCommentCount {
93
+ position: absolute;
94
+ top: 0;
95
+ left: 105px;
96
+ }
97
+
98
+ .statsBox .statsRating {
99
+ position: absolute;
100
+ top: 0;
101
+ left: 141px;
102
+ }
103
+ </style>
104
+ </head>
105
+
106
+ <body>
107
+ <input
108
+ class="searchBox"
109
+ id="search"
110
+ type="text"
111
+ onkeyup="javascript:searchModels(this.value);"
112
+ placeholder="search"
113
+ />
114
+ <button
115
+ onclick="javascript:clearCurrentSearchValue(); javascript:searchModels(getCurrentSearchValue())"
116
+ >
117
+ Clear
118
+ </button>
119
+
120
+ Found: <input class="found" id="found" type="text" readonly />
121
+
122
+ <label for="searchMode">Mode</label>
123
+ <select
124
+ name="searchMode"
125
+ id="searchMode"
126
+ onchange="javascript:searchModels(getCurrentSearchValue());"
127
+ >
128
+ <option value="available">Available</option>
129
+ <option value="missing">Missing</option>
130
+ </select>
131
+
132
+ <label>
133
+ <input
134
+ id="selectedLora"
135
+ type="checkbox"
136
+ onclick="javascript:searchModels(getCurrentSearchValue());"
137
+ />
138
+ LoRA
139
+ </label>
140
+
141
+ <label>
142
+ <input
143
+ id="selectedLocon"
144
+ type="checkbox"
145
+ onclick="javascript:searchModels(getCurrentSearchValue());"
146
+ />
147
+ LoCon
148
+ </label>
149
+
150
+ <label>
151
+ <input
152
+ id="selectedEmbedding"
153
+ type="checkbox"
154
+ onclick="javascript:searchModels(getCurrentSearchValue());"
155
+ />
156
+ Embedding
157
+ </label>
158
+
159
+ <label>
160
+ <input
161
+ id="selectedFlux"
162
+ type="checkbox"
163
+ onclick="javascript:searchModels(getCurrentSearchValue());"
164
+ />
165
+ Flux
166
+ </label>
167
+
168
+ <div id="mainContent" class="mainContent"></div>
169
+
170
+ <script type="text/javascript">
171
+ function yesNo(value) {
172
+ if (value === undefined) {
173
+ return '❓';
174
+ }
175
+ return value ? '✅' : '❌';
176
+ }
177
+
178
+ const notMatched = {
179
+ lycoris: [],
180
+ lora: [],
181
+ embedding: [],
182
+ flux: [],
183
+ };
184
+
185
+ models.lycorises.forEach((lycoris) => {
186
+ const key = prepareKey(lycoris.name);
187
+ if (presence[key] !== undefined) {
188
+ presence[key].loconCivitai = true;
189
+
190
+ setImageUrl(key, lycoris.imageUrl);
191
+ presence[key].loconCivitaiLink = lycoris.url;
192
+ } else if (!isKnownSkippableKey(key)) {
193
+ notMatched.lycoris.push(key);
194
+ }
195
+ });
196
+
197
+ models.loras.forEach((lora) => {
198
+ const key = prepareKey(lora.name);
199
+ if (presence[key] !== undefined) {
200
+ presence[key].loraCivitai = true;
201
+
202
+ setImageUrl(key, lora.imageUrl);
203
+ presence[key].loraCivitaiLink = lora.url;
204
+ } else if (!isKnownSkippableKey(key)) {
205
+ notMatched.lora.push(key);
206
+ }
207
+ });
208
+
209
+ models.embeddings.forEach((embedding) => {
210
+ const key = prepareKey(embedding.name);
211
+ if (presence[key] !== undefined) {
212
+ presence[key].embeddingCivitai = true;
213
+
214
+ setImageUrl(key, embedding.imageUrl);
215
+ presence[key].embeddingCivitaiLink = embedding.url;
216
+ } else if (!isKnownSkippableKey(key)) {
217
+ notMatched.embedding.push(key);
218
+ }
219
+ });
220
+
221
+ console.log(notMatched);
222
+
223
+ const presenceModels = [];
224
+ for (const property in presence) {
225
+ const element = {
226
+ key: property,
227
+ locon: presence[property].locon,
228
+ lora: presence[property].lora,
229
+ embedding: presence[property].embedding,
230
+ flux: presence[property].flux,
231
+ mega: undefined,
232
+ imageUrl: presence[property]?.imageUrl ?? undefined,
233
+ };
234
+ presenceModels.push(element);
235
+ }
236
+
237
+ searchModels(getCurrentSearchValue());
238
+ </script>
239
+ </body>
unknown.jpg ADDED