forked from bukkumaaku/auto-tagger-eagle-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
575 lines (567 loc) · 26.4 KB
/
index.html
File metadata and controls
575 lines (567 loc) · 26.4 KB
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
/>
<script src="js/lib/vue.global.js"></script>
<script src="js/lib/naiveui.js"></script>
<script src="js/utils/tagset.js"></script>
<script src="js/utils/tool.js"></script>
<script src="js/utils/download-models.js"></script>
<script src="js/plugin.js"></script>
<style>
.questionMark {
width: 19px;
height: 19px;
margin-right: 5px;
}
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
margin: 0;
}
#app {
width: 90%;
height: fit-content;
}
@media (max-width: 800px) {
#app {
max-width: 600px;
}
}
</style>
</head>
<body>
<div id="app">
<n-config-provider :theme="theme">
<n-space
justify="space-between"
style="
width: 100%;
height: 30px;
position: fixed;
top: 0px;
left: 0px;
-webkit-app-region: drag;
z-index: 10000;
"
>
<n-thing
style="
height: 30px;
line-height: 30px;
margin-left: 10px;
"
>Automatic Labeling</n-thing
>
<!-- 最小化和关闭按钮 -->
<n-thing>
<n-button
@click="handleMinimize"
size="small"
type="text"
style="-webkit-app-region: no-drag"
>
<img
src="./images/min.png"
style="width: 18px; height: 18px"
/>
</n-button>
<n-button
@click="handleClose"
size="small"
type="text"
style="-webkit-app-region: no-drag"
>
<img
src="./images/close.png"
style="width: 18px; height: 18px"
/>
</n-button>
</n-thing>
</n-space>
<n-divider
style="position: fixed; top: 5px; left: 0px; width: 100%"
></n-divider>
<n-form
:model="formData"
label-placement="left"
label-width="auto"
style="
width: 75% !important;
margin: auto auto;
position: relative;
margin-top: 30px;
"
>
<n-form-item label="Progress" path="modelName">
<n-thing>{{ allItem }}/{{ completeItem }}</n-thing>
<n-progress
type="line"
:percentage="Number((completeItem / allItem * 100).toFixed(2))"
indicator-placement="inside"
/>
</n-form-item>
<!-- 模型位置 -->
<n-form-item label="Model Location" path="modelPath">
<n-select
v-model:value="formData.modelPath"
:options="options"
style="width: 70%"
></n-select>
<n-button
type="primary"
@click="showModal = true"
style="margin: auto; margin-right: 0px"
>
Model Download Window
</n-button>
</n-form-item>
<!-- 阈值 -->
<n-form-item label="Threshold" path="threshold"
><n-tooltip trigger="hover">
<template #trigger>
<div
v-html="questionMark"
class="questionMark"
></div>
</template>
The higher the threshold, the fewer labels are generated, but the accuracy of the labels is higher.
<br />
The lower the threshold, the more labels are generated, but the accuracy of the labels decreases.
</n-tooltip>
<n-input-number
v-model:value="formData.threshold"
:min="0"
:max="1"
:step="0.01"
/>
</n-form-item>
<!-- 步数 -->
<n-form-item label="Batch Size" path="steps">
<n-tooltip trigger="hover">
<template #trigger>
<div
v-html="questionMark"
class="questionMark"
></div>
</template>
It is recommended that the number of images processed in each batch should not be too large.
</n-tooltip>
<n-input-number
v-model:value="formData.steps"
:min="1"
:max="40"
/>
</n-form-item>
<!-- 过滤标签 -->
<n-form-item label="Filter Tags" path="filterTags">
<n-tooltip trigger="hover">
<template #trigger>
<div
v-html="questionMark"
class="questionMark"
></div>
</template>
Filtered tags will not be written to the tag group in the file.
</n-tooltip>
<n-select
filterable
multiple
tag
:show="false"
:show-arrow="false"
v-model:value="formData.filterTags"
placeholder="Enter the filter tags (in English), then press Enter to confirm."
/>
</n-form-item>
<!-- 是否覆写 -->
<n-form-item label="Overwrite" path="overwrite">
<n-tooltip trigger="hover">
<template #trigger>
<div
v-html="questionMark"
class="questionMark"
></div>
</template>
Do not overwrite: Directly skip files that already have tags (this is the fastest option if many files already have tags).<br />
Overwrite: If a tag exists, it will be overwritten (this process is time-consuming).<br />
Merging: Merging will be performed if there are labels (this is the most time-consuming process).
</n-tooltip>
<n-radio-group
v-model:value="formData.overwrite"
name="overwrite"
>
<n-space>
<n-radio value="nocover">Do not Overwrite</n-radio>
<n-radio value="cover">Overwrite</n-radio>
<n-radio value="merge">Merge</n-radio>
</n-space>
</n-radio-group>
</n-form-item>
<!-- 是否识别视频 -->
<n-form-item label="Read Video" path="readVideo">
<n-tooltip trigger="hover">
<template #trigger>
<div
v-html="questionMark"
class="questionMark"
></div>
</template>
The video content will be read, and image recognition will be performed on the frames at 1%, 20%, 40%, 60%, 80%, and 99% of the video duration.<br />
The speed of tagging video files will be significantly reduced.<br />
You need to install ffmpeg from the plugin center beforehand.
</n-tooltip>
<n-radio-group
v-model:value="formData.readVideo"
name="readVideo"
>
<n-space>
<n-radio value="noread">Do not read the video content.</n-radio>
<n-radio value="read">Read and label</n-radio>
</n-space>
</n-radio-group>
</n-form-item>
<!-- 标签语言选择 -->
<n-form-item label="Language" path="language">
<n-radio-group
v-model:value="formData.language"
name="language"
>
<n-space>
<n-radio value="zh">Chinese</n-radio>
<n-radio value="en">English</n-radio>
<n-radio value="mix">Chinese + English</n-radio>
</n-space>
</n-radio-group>
</n-form-item>
<!-- 分隔符 -->
<n-form-item label="Splitter" path="splitter">
<n-tooltip trigger="hover">
<template #trigger>
<div
v-html="questionMark"
class="questionMark"
></div>
</template>
The separator is only needed when both Chinese and English labels are present.
</n-tooltip>
<n-input
v-model:value="formData.splitter"
:placeholder="formData.language === 'mix' ? 'Please enter the separator.' : 'The separator is only needed when both Chinese and English labels are present.'"
:disabled="formData.language !== 'mix'"
/>
</n-form-item>
<!-- 启动自动打标 -->
<n-form-item label="Autotagger" path="autotagger">
<n-tooltip trigger="hover">
<template #trigger>
<div
v-html="questionMark"
class="questionMark"
></div>
</template>
After opening the software, it automatically labels the unlabeled images, using the labeling parameters from the previous labeling session.<br />
Label Override: Do not override
</n-tooltip>
<n-switch v-model:value="formData.autotagger" />
</n-form-item>
<!-- 操作按钮 -->
<div
style="
display: flex;
gap: 10px;
justify-content: flex-end;
"
>
<n-button type="primary" @click="handleSubmit(false)"
>Process</n-button
>
<n-button @click="handleReset">Restore Defaults</n-button>
</div>
</n-form>
<n-modal
v-model:show="showModal"
preset="card"
title="Download Model Resources"
:mask-closable="!isDownloading"
:close-on-esc="!isDownloading"
:closable="!isDownloading"
:on-close="handleCloseModal"
style="width: 85%"
>
<n-space vertical size="large">
<n-card embedded :bordered="false" size="small">
<n-space vertical>
<div class="setting-row">
<span class="label">Select Model:</span>
<n-select
v-model:value="selectedModel"
:options="modelOptions"
:disabled="isDownloading"
placeholder="Please select the model you want to use."
style="width: 300px"
/>
</div>
<div class="setting-row">
<span class="label">Download Source:</span>
<n-radio-group
v-model:value="downloadSource"
:disabled="isDownloading"
>
<n-radio-button value="direct">
HuggingFace Direct Connection
</n-radio-button>
<n-radio-button value="mirror">
Domestic Mirror (HF-Mirror)
</n-radio-button>
</n-radio-group>
</div>
</n-space>
</n-card>
<div
v-if="!isDownloading"
style="display: flex; justify-content: flex-end"
>
<n-button
type="primary"
size="large"
@click="startDownload"
:disabled="!selectedModel"
>
Start Downloading
</n-button>
</div>
<n-collapse-transition :show="isDownloading">
<n-card
title="Download Progress"
embedded
:bordered="false"
size="small"
>
<template #header-extra>
<n-tag type="info" size="small" round>
Speed: {{ currentSpeed }}
</n-tag>
</template>
<n-space vertical size="medium">
<div class="progress-item">
<div class="progress-label">
<span>selected_tags.csv</span>
</div>
<n-progress
type="line"
:percentage="progressTags"
:indicator-placement="'inside'"
processing
status="success"
/>
</div>
<div class="progress-item">
<div class="progress-label">
<span> model.onnx</span>
</div>
<n-progress
type="line"
:percentage="progressModel"
:indicator-placement="'inside'"
processing
:status="progressModel === 100 ? 'success' : 'info'"
/>
</div>
</n-space>
<div class="download-footer">
<n-spin
size="small"
v-if="progressModel < 100"
/>
<span style="margin-left: 8px">
{{ progressModel < 100 ?
'Currently downloading resources, please close the window...' :
'Download Complete!Currently verifying file...' }}
</span>
</div>
</n-card>
</n-collapse-transition>
</n-space>
</n-modal>
</n-config-provider>
</div>
<script>
const { createApp, ref, h } = Vue;
// 引用通知组件
const sendNotification = naive.createDiscreteApi([
"notification",
"dialog",
"modal",
]);
let config = {};
async function main() {
// 获取配置
config = await getConfig();
const originalConfig = JSON.parse(JSON.stringify(config));
createApp({
setup() {
const theme = naive.darkTheme;
const formData = ref(config);
// 提交处理
const handleSubmit = async (isAll = false) => {
if (formData.value.modelPath === "") {
notification("Please select model path");
return;
}
if (is_processing) {
notification("There is still a task in progress, please wait");
return;
}
is_processing = true;
await initialize(isAll);
await wait(500);
config = formData.value;
await setConfig(config);
await startGetTag(config);
};
// 重置表单
const handleReset = () => {
formData.value = originalConfig;
};
const handleMinimize = async () => {
await eagle.window.minimize();
};
const handleClose = async () => {
await eagle.window.hide();
};
const downloadModel = async () => {};
const options = ref([]);
const allItem = ref(0);
const completeItem = ref(0);
const questionMark = ref(
`<img src="./images/img.icons8.png" class="questionMark">`
);
const showModal = ref(false);
const isDownloading = ref(false);
const downloadSource = ref("mirror");
const currentSpeed = ref("0 B/s");
const progressTags = ref(0);
const progressModel = ref(0);
const selectedModel = ref("wd-eva02-large-tagger-v3");
const modelOptions = [
{
label: "wd-eva02-large-tagger-v3",
value: "wd-eva02-large-tagger-v3",
type: "wd",
},
{
label: "wd-vit-tagger-v3",
value: "wd-vit-tagger-v3",
type: "wd",
},
{
label: "wd-vit-large-tagger-v3",
value: "wd-vit-large-tagger-v3",
type: "wd",
},
{
label: "wd-v1-4-moat-tagger-v2",
value: "wd-v1-4-moat-tagger-v2",
type: "wd",
},
{
label: "cl_tagger",
value: "cl_tagger",
type: "cl",
},
{
label: "camie-tagger-v2",
value: "camie-tagger-v2",
type: "ca",
},
];
const handleCloseModal = () => {
showModal.value = false;
};
const onProgress = (percentage, speed, type) => {
if (type === "model")
progressModel.value = Number(percentage);
else progressTags.value = Number(percentage);
currentSpeed.value = speed;
};
const startDownload = async () => {
isDownloading.value = true;
progressTags.value = 0;
progressModel.value = 0;
currentSpeed.value = "Connecting...";
let modelType = "";
for (let i = 0; i < modelOptions.length; i++) {
if (
modelOptions[i].value ===
selectedModel.value
) {
modelType = modelOptions[i].type;
break;
}
}
await downloadFile(
selectedModel.value,
downloadSource.value,
modelType,
onProgress
);
await finishDownload();
};
const finishDownload = async () => {
isDownloading.value = false;
alert(
"Model downloading completed, refresh the plugin to apply new model",
"Download Complete",
{
type: "success",
}
);
window.location.reload();
};
window.options = options;
window.formData = formData;
window.allItem = allItem;
window.completeItem = completeItem;
window.handleSubmit = handleSubmit;
return {
formData,
handleSubmit,
handleReset,
options,
allItem,
completeItem,
questionMark,
theme,
handleClose,
handleMinimize,
downloadModel,
showModal,
isDownloading,
downloadSource,
currentSpeed,
progressTags,
progressModel,
modelOptions,
handleCloseModal,
startDownload,
selectedModel,
};
},
})
.use(naive)
.mount("#app");
await wait(1000);
await autotaggerFun(config);
}
main();
</script>
</body>
</html>