faisalhr1997 narugo commited on
Commit
5a2f941
0 Parent(s):

Duplicate from deepghs/wd14_tagging_online

Browse files

Co-authored-by: narugo1992 <[email protected]>

Files changed (5) hide show
  1. .gitattributes +34 -0
  2. .gitignore +1215 -0
  3. README.md +14 -0
  4. app.py +184 -0
  5. requirements.txt +8 -0
.gitattributes ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tflite filter=lfs diff=lfs merge=lfs -text
29
+ *.tgz filter=lfs diff=lfs merge=lfs -text
30
+ *.wasm filter=lfs diff=lfs merge=lfs -text
31
+ *.xz filter=lfs diff=lfs merge=lfs -text
32
+ *.zip filter=lfs diff=lfs merge=lfs -text
33
+ *.zst filter=lfs diff=lfs merge=lfs -text
34
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1,1215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Created by .ignore support plugin (hsz.mobi)
2
+ ### Example user template template
3
+ ### Example user template
4
+
5
+ # IntelliJ project files
6
+ .idea
7
+ *.iml
8
+ out
9
+ gen
10
+ ### CVS template
11
+ /CVS/*
12
+ **/CVS/*
13
+ .cvsignore
14
+ */.cvsignore
15
+
16
+ ### C++ template
17
+ # Prerequisites
18
+ *.d
19
+
20
+ # Compiled Object files
21
+ *.slo
22
+ *.lo
23
+ *.o
24
+ *.obj
25
+
26
+ # Precompiled Headers
27
+ *.gch
28
+ *.pch
29
+
30
+ # Compiled Dynamic libraries
31
+ *.so
32
+ *.dylib
33
+ *.dll
34
+
35
+ # Fortran module files
36
+ *.mod
37
+ *.smod
38
+
39
+ # Compiled Static libraries
40
+ *.lai
41
+ *.la
42
+ *.a
43
+ *.lib
44
+
45
+ # Executables
46
+ *.exe
47
+ *.out
48
+ *.app
49
+
50
+ ### CUDA template
51
+ *.i
52
+ *.ii
53
+ *.gpu
54
+ *.ptx
55
+ *.cubin
56
+ *.fatbin
57
+
58
+ ### SVN template
59
+ .svn/
60
+
61
+ ### Images template
62
+ # JPEG
63
+ *.jpe
64
+ *.jif
65
+ *.jfif
66
+ *.jfi
67
+
68
+ # JPEG 2000
69
+ *.jp2
70
+ *.j2k
71
+ *.jpf
72
+ *.jpx
73
+ *.jpm
74
+ *.mj2
75
+
76
+ # JPEG XR
77
+ *.jxr
78
+ *.hdp
79
+ *.wdp
80
+
81
+ # Graphics Interchange Format
82
+ *.gif
83
+
84
+ # RAW
85
+ *.raw
86
+
87
+ # Web P
88
+ *.webp
89
+
90
+ # Animated Portable Network Graphics
91
+ *.apng
92
+
93
+ # Multiple-image Network Graphics
94
+ *.mng
95
+
96
+ # Tagged Image File Format
97
+ *.tiff
98
+ *.tif
99
+
100
+ # Scalable Vector Graphics
101
+ *.svg
102
+ *.svgz
103
+
104
+ # Portable Document Format
105
+ *.pdf
106
+
107
+ # X BitMap
108
+ *.xbm
109
+
110
+ # BMP
111
+ *.bmp
112
+ *.dib
113
+
114
+ # ICO
115
+ *.ico
116
+
117
+ # 3D Images
118
+ *.3dm
119
+ *.max
120
+
121
+ ### Eclipse template
122
+ .metadata
123
+ bin/
124
+ tmp/
125
+ *.tmp
126
+ *.bak
127
+ *.swp
128
+ *~.nib
129
+ local.properties
130
+ .settings/
131
+ .loadpath
132
+ .recommenders
133
+
134
+ # External tool builders
135
+ .externalToolBuilders/
136
+
137
+ # Locally stored "Eclipse launch configurations"
138
+ *.launch
139
+
140
+ # PyDev specific (Python IDE for Eclipse)
141
+ *.pydevproject
142
+
143
+ # CDT-specific (C/C++ Development Tooling)
144
+ .cproject
145
+
146
+ # CDT- autotools
147
+ .autotools
148
+
149
+ # Java annotation processor (APT)
150
+ .factorypath
151
+
152
+ # PDT-specific (PHP Development Tools)
153
+ .buildpath
154
+
155
+ # sbteclipse plugin
156
+ .target
157
+
158
+ # Tern plugin
159
+ .tern-project
160
+
161
+ # TeXlipse plugin
162
+ .texlipse
163
+
164
+ # STS (Spring Tool Suite)
165
+ .springBeans
166
+
167
+ # Code Recommenders
168
+ .recommenders/
169
+
170
+ # Annotation Processing
171
+ .apt_generated/
172
+ .apt_generated_test/
173
+
174
+ # Scala IDE specific (Scala & Java development for Eclipse)
175
+ .cache-main
176
+ .scala_dependencies
177
+ .worksheet
178
+
179
+ # Uncomment this line if you wish to ignore the project description file.
180
+ # Typically, this file would be tracked if it contains build/dependency configurations:
181
+ #.project
182
+
183
+ ### Diff template
184
+ *.patch
185
+ *.diff
186
+
187
+ ### macOS template
188
+ # General
189
+ .DS_Store
190
+ .AppleDouble
191
+ .LSOverride
192
+
193
+ # Icon must end with two \r
194
+ Icon
195
+
196
+ # Thumbnails
197
+ ._*
198
+
199
+ # Files that might appear in the root of a volume
200
+ .DocumentRevisions-V100
201
+ .fseventsd
202
+ .Spotlight-V100
203
+ .TemporaryItems
204
+ .Trashes
205
+ .VolumeIcon.icns
206
+ .com.apple.timemachine.donotpresent
207
+
208
+ # Directories potentially created on remote AFP share
209
+ .AppleDB
210
+ .AppleDesktop
211
+ Network Trash Folder
212
+ Temporary Items
213
+ .apdisk
214
+
215
+ ### CMake template
216
+ CMakeLists.txt.user
217
+ CMakeCache.txt
218
+ CMakeFiles
219
+ CMakeScripts
220
+ Testing
221
+ cmake_install.cmake
222
+ install_manifest.txt
223
+ compile_commands.json
224
+ CTestTestfile.cmake
225
+ _deps
226
+
227
+ ### Linux template
228
+ *~
229
+
230
+ # temporary files which can be created if a process still has a handle open of a deleted file
231
+ .fuse_hidden*
232
+
233
+ # KDE directory preferences
234
+ .directory
235
+
236
+ # Linux trash folder which might appear on any partition or disk
237
+ .Trash-*
238
+
239
+ # .nfs files are created when an open file is removed but is still being accessed
240
+ .nfs*
241
+
242
+ ### MicrosoftOffice template
243
+ *.tmp
244
+
245
+ # Word temporary
246
+ ~$*.doc*
247
+
248
+ # Word Auto Backup File
249
+ Backup of *.doc*
250
+
251
+ # Excel temporary
252
+ ~$*.xls*
253
+
254
+ # Excel Backup File
255
+ *.xlk
256
+
257
+ # PowerPoint temporary
258
+ ~$*.ppt*
259
+
260
+ # Visio autosave temporary files
261
+ *.~vsd*
262
+
263
+ ### VisualStudio template
264
+ ## Ignore Visual Studio temporary files, build results, and
265
+ ## files generated by popular Visual Studio add-ons.
266
+ ##
267
+ ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
268
+
269
+ # User-specific files
270
+ *.rsuser
271
+ *.suo
272
+ *.user
273
+ *.userosscache
274
+ *.sln.docstates
275
+
276
+ # User-specific files (MonoDevelop/Xamarin Studio)
277
+ *.userprefs
278
+
279
+ # Mono auto generated files
280
+ mono_crash.*
281
+
282
+ # Build results
283
+ [Dd]ebug/
284
+ [Dd]ebugPublic/
285
+ [Rr]elease/
286
+ [Rr]eleases/
287
+ x64/
288
+ x86/
289
+ [Ww][Ii][Nn]32/
290
+ [Aa][Rr][Mm]/
291
+ [Aa][Rr][Mm]64/
292
+ bld/
293
+ [Bb]in/
294
+ [Oo]bj/
295
+ [Ll]og/
296
+ [Ll]ogs/
297
+
298
+ # Visual Studio 2015/2017 cache/options directory
299
+ .vs/
300
+ # Uncomment if you have tasks that create the project's static files in wwwroot
301
+ #wwwroot/
302
+
303
+ # Visual Studio 2017 auto generated files
304
+ Generated\ Files/
305
+
306
+ # MSTest test Results
307
+ [Tt]est[Rr]esult*/
308
+ [Bb]uild[Ll]og.*
309
+
310
+ # NUnit
311
+ *.VisualState.xml
312
+ TestResult.xml
313
+ nunit-*.xml
314
+
315
+ # Build Results of an ATL Project
316
+ [Dd]ebugPS/
317
+ [Rr]eleasePS/
318
+ dlldata.c
319
+
320
+ # Benchmark Results
321
+ BenchmarkDotNet.Artifacts/
322
+
323
+ # .NET Core
324
+ project.lock.json
325
+ project.fragment.lock.json
326
+ artifacts/
327
+
328
+ # ASP.NET Scaffolding
329
+ ScaffoldingReadMe.txt
330
+
331
+ # StyleCop
332
+ StyleCopReport.xml
333
+
334
+ # Files built by Visual Studio
335
+ *_i.c
336
+ *_p.c
337
+ *_h.h
338
+ *.ilk
339
+ *.meta
340
+ *.obj
341
+ *.iobj
342
+ *.pch
343
+ *.pdb
344
+ *.ipdb
345
+ *.pgc
346
+ *.pgd
347
+ *.rsp
348
+ *.sbr
349
+ *.tlb
350
+ *.tli
351
+ *.tlh
352
+ *.tmp
353
+ *.tmp_proj
354
+ *_wpftmp.csproj
355
+ *.log
356
+ *.vspscc
357
+ *.vssscc
358
+ .builds
359
+ *.pidb
360
+ *.svclog
361
+ *.scc
362
+
363
+ # Chutzpah Test files
364
+ _Chutzpah*
365
+
366
+ # Visual C++ cache files
367
+ ipch/
368
+ *.aps
369
+ *.ncb
370
+ *.opendb
371
+ *.opensdf
372
+ *.sdf
373
+ *.cachefile
374
+ *.VC.db
375
+ *.VC.VC.opendb
376
+
377
+ # Visual Studio profiler
378
+ *.psess
379
+ *.vsp
380
+ *.vspx
381
+ *.sap
382
+
383
+ # Visual Studio Trace Files
384
+ *.e2e
385
+
386
+ # TFS 2012 Local Workspace
387
+ $tf/
388
+
389
+ # Guidance Automation Toolkit
390
+ *.gpState
391
+
392
+ # ReSharper is a .NET coding add-in
393
+ _ReSharper*/
394
+ *.[Rr]e[Ss]harper
395
+ *.DotSettings.user
396
+
397
+ # TeamCity is a build add-in
398
+ _TeamCity*
399
+
400
+ # DotCover is a Code Coverage Tool
401
+ *.dotCover
402
+
403
+ # AxoCover is a Code Coverage Tool
404
+ .axoCover/*
405
+ !.axoCover/settings.json
406
+
407
+ # Coverlet is a free, cross platform Code Coverage Tool
408
+ coverage*.json
409
+ coverage*.xml
410
+ coverage*.info
411
+
412
+ # Visual Studio code coverage results
413
+ *.coverage
414
+ *.coveragexml
415
+
416
+ # NCrunch
417
+ _NCrunch_*
418
+ .*crunch*.local.xml
419
+ nCrunchTemp_*
420
+
421
+ # MightyMoose
422
+ *.mm.*
423
+ AutoTest.Net/
424
+
425
+ # Web workbench (sass)
426
+ .sass-cache/
427
+
428
+ # Installshield output folder
429
+ [Ee]xpress/
430
+
431
+ # DocProject is a documentation generator add-in
432
+ DocProject/buildhelp/
433
+ DocProject/Help/*.HxT
434
+ DocProject/Help/*.HxC
435
+ DocProject/Help/*.hhc
436
+ DocProject/Help/*.hhk
437
+ DocProject/Help/*.hhp
438
+ DocProject/Help/Html2
439
+ DocProject/Help/html
440
+
441
+ # Click-Once directory
442
+ publish/
443
+
444
+ # Publish Web Output
445
+ *.[Pp]ublish.xml
446
+ *.azurePubxml
447
+ # Note: Comment the next line if you want to checkin your web deploy settings,
448
+ # but database connection strings (with potential passwords) will be unencrypted
449
+ *.pubxml
450
+ *.publishproj
451
+
452
+ # Microsoft Azure Web App publish settings. Comment the next line if you want to
453
+ # checkin your Azure Web App publish settings, but sensitive information contained
454
+ # in these scripts will be unencrypted
455
+ PublishScripts/
456
+
457
+ # NuGet Packages
458
+ *.nupkg
459
+ # NuGet Symbol Packages
460
+ *.snupkg
461
+ # The packages folder can be ignored because of Package Restore
462
+ **/[Pp]ackages/*
463
+ # except build/, which is used as an MSBuild target.
464
+ !**/[Pp]ackages/build/
465
+ # Uncomment if necessary however generally it will be regenerated when needed
466
+ #!**/[Pp]ackages/repositories.config
467
+ # NuGet v3's project.json files produces more ignorable files
468
+ *.nuget.props
469
+ *.nuget.targets
470
+
471
+ # Microsoft Azure Build Output
472
+ csx/
473
+ *.build.csdef
474
+
475
+ # Microsoft Azure Emulator
476
+ ecf/
477
+ rcf/
478
+
479
+ # Windows Store app package directories and files
480
+ AppPackages/
481
+ BundleArtifacts/
482
+ Package.StoreAssociation.xml
483
+ _pkginfo.txt
484
+ *.appx
485
+ *.appxbundle
486
+ *.appxupload
487
+
488
+ # Visual Studio cache files
489
+ # files ending in .cache can be ignored
490
+ *.[Cc]ache
491
+ # but keep track of directories ending in .cache
492
+ !?*.[Cc]ache/
493
+
494
+ # Others
495
+ ClientBin/
496
+ ~$*
497
+ *~
498
+ *.dbmdl
499
+ *.dbproj.schemaview
500
+ *.jfm
501
+ *.pfx
502
+ *.publishsettings
503
+ orleans.codegen.cs
504
+
505
+ # Including strong name files can present a security risk
506
+ # (https://github.com/github/gitignore/pull/2483#issue-259490424)
507
+ #*.snk
508
+
509
+ # Since there are multiple workflows, uncomment next line to ignore bower_components
510
+ # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
511
+ #bower_components/
512
+
513
+ # RIA/Silverlight projects
514
+ Generated_Code/
515
+
516
+ # Backup & report files from converting an old project file
517
+ # to a newer Visual Studio version. Backup files are not needed,
518
+ # because we have git ;-)
519
+ _UpgradeReport_Files/
520
+ Backup*/
521
+ UpgradeLog*.XML
522
+ UpgradeLog*.htm
523
+ ServiceFabricBackup/
524
+ *.rptproj.bak
525
+
526
+ # SQL Server files
527
+ *.mdf
528
+ *.ldf
529
+ *.ndf
530
+
531
+ # Business Intelligence projects
532
+ *.rdl.data
533
+ *.bim.layout
534
+ *.bim_*.settings
535
+ *.rptproj.rsuser
536
+ *- [Bb]ackup.rdl
537
+ *- [Bb]ackup ([0-9]).rdl
538
+ *- [Bb]ackup ([0-9][0-9]).rdl
539
+
540
+ # Microsoft Fakes
541
+ FakesAssemblies/
542
+
543
+ # GhostDoc plugin setting file
544
+ *.GhostDoc.xml
545
+
546
+ # Node.js Tools for Visual Studio
547
+ .ntvs_analysis.dat
548
+ node_modules/
549
+
550
+ # Visual Studio 6 build log
551
+ *.plg
552
+
553
+ # Visual Studio 6 workspace options file
554
+ *.opt
555
+
556
+ # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
557
+ *.vbw
558
+
559
+ # Visual Studio LightSwitch build output
560
+ **/*.HTMLClient/GeneratedArtifacts
561
+ **/*.DesktopClient/GeneratedArtifacts
562
+ **/*.DesktopClient/ModelManifest.xml
563
+ **/*.Server/GeneratedArtifacts
564
+ **/*.Server/ModelManifest.xml
565
+ _Pvt_Extensions
566
+
567
+ # Paket dependency manager
568
+ .paket/paket.exe
569
+ paket-files/
570
+
571
+ # FAKE - F# Make
572
+ .fake/
573
+
574
+ # CodeRush personal settings
575
+ .cr/personal
576
+
577
+ # Python Tools for Visual Studio (PTVS)
578
+ __pycache__/
579
+ *.pyc
580
+
581
+ # Cake - Uncomment if you are using it
582
+ # tools/**
583
+ # !tools/packages.config
584
+
585
+ # Tabs Studio
586
+ *.tss
587
+
588
+ # Telerik's JustMock configuration file
589
+ *.jmconfig
590
+
591
+ # BizTalk build output
592
+ *.btp.cs
593
+ *.btm.cs
594
+ *.odx.cs
595
+ *.xsd.cs
596
+
597
+ # OpenCover UI analysis results
598
+ OpenCover/
599
+
600
+ # Azure Stream Analytics local run output
601
+ ASALocalRun/
602
+
603
+ # MSBuild Binary and Structured Log
604
+ *.binlog
605
+
606
+ # NVidia Nsight GPU debugger configuration file
607
+ *.nvuser
608
+
609
+ # MFractors (Xamarin productivity tool) working folder
610
+ .mfractor/
611
+
612
+ # Local History for Visual Studio
613
+ .localhistory/
614
+
615
+ # BeatPulse healthcheck temp database
616
+ healthchecksdb
617
+
618
+ # Backup folder for Package Reference Convert tool in Visual Studio 2017
619
+ MigrationBackup/
620
+
621
+ # Ionide (cross platform F# VS Code tools) working folder
622
+ .ionide/
623
+
624
+ # Fody - auto-generated XML schema
625
+ FodyWeavers.xsd
626
+
627
+ ### Vim template
628
+ # Swap
629
+ [._]*.s[a-v][a-z]
630
+ !*.svg # comment out if you don't need vector files
631
+ [._]*.sw[a-p]
632
+ [._]s[a-rt-v][a-z]
633
+ [._]ss[a-gi-z]
634
+ [._]sw[a-p]
635
+
636
+ # Session
637
+ Session.vim
638
+ Sessionx.vim
639
+
640
+ # Temporary
641
+ .netrwhist
642
+ *~
643
+ # Auto-generated tag files
644
+ tags
645
+ # Persistent undo
646
+ [._]*.un~
647
+
648
+ ### Backup template
649
+ *.bak
650
+ *.gho
651
+ *.ori
652
+ *.orig
653
+ *.tmp
654
+
655
+ ### SublimeText template
656
+ # Cache files for Sublime Text
657
+ *.tmlanguage.cache
658
+ *.tmPreferences.cache
659
+ *.stTheme.cache
660
+
661
+ # Workspace files are user-specific
662
+ *.sublime-workspace
663
+
664
+ # Project files should be checked into the repository, unless a significant
665
+ # proportion of contributors will probably not be using Sublime Text
666
+ # *.sublime-project
667
+
668
+ # SFTP configuration file
669
+ sftp-config.json
670
+ sftp-config-alt*.json
671
+
672
+ # Package control specific files
673
+ Package Control.last-run
674
+ Package Control.ca-list
675
+ Package Control.ca-bundle
676
+ Package Control.system-ca-bundle
677
+ Package Control.cache/
678
+ Package Control.ca-certs/
679
+ Package Control.merged-ca-bundle
680
+ Package Control.user-ca-bundle
681
+ oscrypto-ca-bundle.crt
682
+ bh_unicode_properties.cache
683
+
684
+ # Sublime-github package stores a github token in this file
685
+ # https://packagecontrol.io/packages/sublime-github
686
+ GitHub.sublime-settings
687
+
688
+ ### C template
689
+ # Prerequisites
690
+ *.d
691
+
692
+ # Object files
693
+ *.o
694
+ *.ko
695
+ *.obj
696
+ *.elf
697
+
698
+ # Linker output
699
+ *.ilk
700
+ *.map
701
+ *.exp
702
+
703
+ # Precompiled Headers
704
+ *.gch
705
+ *.pch
706
+
707
+ # Libraries
708
+ *.lib
709
+ *.a
710
+ *.la
711
+ *.lo
712
+
713
+ # Shared objects (inc. Windows DLLs)
714
+ *.dll
715
+ *.so
716
+ *.so.*
717
+ *.dylib
718
+
719
+ # Executables
720
+ *.exe
721
+ *.out
722
+ *.app
723
+ *.i*86
724
+ *.x86_64
725
+ *.hex
726
+
727
+ # Debug files
728
+ *.dSYM/
729
+ *.su
730
+ *.idb
731
+ *.pdb
732
+
733
+ # Kernel Module Compile Results
734
+ *.mod*
735
+ *.cmd
736
+ .tmp_versions/
737
+ modules.order
738
+ Module.symvers
739
+ Mkfile.old
740
+ dkms.conf
741
+
742
+ ### VirtualEnv template
743
+ # Virtualenv
744
+ # http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
745
+ .Python
746
+ [Bb]in
747
+ [Ii]nclude
748
+ [Ll]ib
749
+ [Ll]ib64
750
+ [Ll]ocal
751
+ [Ss]cripts
752
+ pyvenv.cfg
753
+ .venv
754
+ pip-selfcheck.json
755
+
756
+ ### LibreOffice template
757
+ # LibreOffice locks
758
+ .~lock.*#
759
+
760
+ ### Xilinx template
761
+ # gitignore template for Xilinx Vivado Design Suite
762
+ # website: https://www.xilinx.com/support/download.html
763
+
764
+ # [home]
765
+ *.jou
766
+ *.log
767
+ *.debug
768
+ *.str
769
+ *.tmp
770
+ *.os
771
+ *.js
772
+ *.pb
773
+ *.dcp
774
+ *.hwdef
775
+ *.vds
776
+ *.veo
777
+ *.wdf
778
+ *.vdi
779
+ *.dmp
780
+ *.rpx
781
+ *.rpt
782
+ *_stub.v
783
+ *_stub.vhdl
784
+ *_funcsim.v
785
+ *_funcsim.vhdl
786
+ .project
787
+
788
+ # [dir]
789
+ *.cache
790
+ .metadata
791
+ *.data
792
+ *.ipdefs
793
+ .Xil
794
+ *.sdk
795
+ *.hw
796
+ *.ip_user_files
797
+
798
+ ### IP synth
799
+ *_synth_*
800
+
801
+ .jobs
802
+
803
+ ### project synth
804
+ */*.runs/synth*/*.xml
805
+ */*.runs/synth*/*.txt
806
+ */*.runs/synth*/*.sh
807
+ */*.runs/synth*/*.tcl
808
+ */*.runs/synth*/*.bat
809
+ */*.runs/synth*/*.xdc
810
+ !*/*.runs/synth*/*utilization*.rpt
811
+
812
+ *.runs/synth*/*.xml
813
+ *.runs/synth*/*.txt
814
+ *.runs/synth*/*.sh
815
+ *.runs/synth*/*.tcl
816
+ *.runs/synth*/*.bat
817
+ *.runs/synth*/*.xdc
818
+ !*.runs/synth*/*utilization*.rpt
819
+
820
+ ### project impl
821
+ */*.runs/impl*/*.xml
822
+ */*.runs/impl*/*.html
823
+ */*.runs/impl*/*.txt
824
+ */*.runs/impl*/*.sh
825
+ */*.runs/impl*/*.tcl
826
+ */*.runs/impl*/*.bat
827
+ !*/*.runs/impl*/*utilization*.rpt
828
+
829
+ *.runs/impl*/*.xml
830
+ *.runs/impl*/*.html
831
+ *.runs/impl*/*.txt
832
+ *.runs/impl*/*.sh
833
+ *.runs/impl*/*.tcl
834
+ *.runs/impl*/*.bat
835
+ !*.runs/impl*/*utilization*.rpt
836
+
837
+ ### block design
838
+ */*/bd/*/hdl
839
+ */*/*/bd/*/hdl
840
+
841
+ */*/bd/*/*.xdc
842
+ */*/*/bd/*/*.xdc
843
+
844
+ */*/bd/*/ip/*/*.xdc
845
+ */*/*/bd/*/ip/*/*.xdc
846
+
847
+ */*/bd/*/ip/*/*/
848
+ */*/*/bd/*/ip/*/*/
849
+
850
+ */*/bd/*/ip/*/*.vhd
851
+ */*/*/bd/*/ip/*/*.vhd
852
+
853
+ */*/bd/*/ip/*/*.xml
854
+ */*/*/bd/*/ip/*/*.xml
855
+
856
+ *.c
857
+ *.cpp
858
+ *.h
859
+ *.vho
860
+ */*/bd/*/ip/*/*.tcl
861
+ */*/*/bd/*/ip/*/*.tcl
862
+ hw_handoff
863
+ ipshared
864
+
865
+ ### Lua template
866
+ # Compiled Lua sources
867
+ luac.out
868
+
869
+ # luarocks build files
870
+ *.src.rock
871
+ *.zip
872
+
873
+ # Object files
874
+ *.o
875
+ *.os
876
+ *.ko
877
+ *.obj
878
+ *.elf
879
+
880
+ # Precompiled Headers
881
+ *.gch
882
+ *.pch
883
+
884
+ # Libraries
885
+ *.lib
886
+ *.a
887
+ *.la
888
+ *.lo
889
+ *.def
890
+ *.exp
891
+
892
+ # Shared objects (inc. Windows DLLs)
893
+ *.dll
894
+ *.so
895
+ *.so.*
896
+ *.dylib
897
+
898
+ # Executables
899
+ *.exe
900
+ *.out
901
+ *.app
902
+ *.i*86
903
+ *.x86_64
904
+ *.hex
905
+
906
+
907
+ ### Vagrant template
908
+ # General
909
+ .vagrant/
910
+
911
+ # Log files (if you are creating logs in debug mode, uncomment this)
912
+ # *.log
913
+
914
+ ### PuTTY template
915
+ # Private key
916
+ *.ppk
917
+
918
+ ### Patch template
919
+ *.orig
920
+ *.rej
921
+
922
+ ### Python template
923
+ # Byte-compiled / optimized / DLL files
924
+ __pycache__/
925
+ *.py[cod]
926
+ *$py.class
927
+
928
+ # C extensions
929
+ *.so
930
+
931
+ # Distribution / packaging
932
+ .Python
933
+ build/
934
+ develop-eggs/
935
+ /dist
936
+ wheelhouse/
937
+ downloads/
938
+ eggs/
939
+ .eggs/
940
+ lib/
941
+ lib64/
942
+ parts/
943
+ sdist/
944
+ var/
945
+ wheels/
946
+ share/python-wheels/
947
+ *.egg-info/
948
+ .installed.cfg
949
+ *.egg
950
+ MANIFEST
951
+
952
+ # PyInstaller
953
+ # Usually these files are written by a python script from a template
954
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
955
+ *.manifest
956
+ *.spec
957
+
958
+ # Installer logs
959
+ pip-log.txt
960
+ pip-delete-this-directory.txt
961
+
962
+ # Unit test / coverage reports
963
+ htmlcov/
964
+ .tox/
965
+ .nox/
966
+ .coverage
967
+ .coverage.*
968
+ .cache
969
+ nosetests.xml
970
+ coverage.xml
971
+ *.cover
972
+ *.py,cover
973
+ .hypothesis/
974
+ .pytest_cache/
975
+ cover/
976
+
977
+ # Translations
978
+ *.mo
979
+ *.pot
980
+
981
+ # Django stuff:
982
+ *.log
983
+ local_settings.py
984
+ db.sqlite3
985
+ db.sqlite3-journal
986
+
987
+ # Flask stuff:
988
+ instance/
989
+ .webassets-cache
990
+
991
+ # Scrapy stuff:
992
+ .scrapy
993
+
994
+ # Sphinx documentation
995
+ docs/_build/
996
+
997
+ # PyBuilder
998
+ .pybuilder/
999
+ target/
1000
+
1001
+ # Jupyter Notebook
1002
+ .ipynb_checkpoints
1003
+
1004
+ # IPython
1005
+ profile_default/
1006
+ ipython_config.py
1007
+
1008
+ # pyenv
1009
+ # For a library or package, you might want to ignore these files since the code is
1010
+ # intended to run in multiple environments; otherwise, check them in:
1011
+ # .python-version
1012
+
1013
+ # pipenv
1014
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
1015
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
1016
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
1017
+ # install all needed dependencies.
1018
+ #Pipfile.lock
1019
+
1020
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
1021
+ __pypackages__/
1022
+
1023
+ # Celery stuff
1024
+ celerybeat-schedule
1025
+ celerybeat.pid
1026
+
1027
+ # SageMath parsed files
1028
+ *.sage.py
1029
+
1030
+ # Environments
1031
+ .env
1032
+ .venv
1033
+ /env/
1034
+ venv/
1035
+ ENV/
1036
+ env.bak/
1037
+ venv.bak/
1038
+
1039
+ # Spyder project settings
1040
+ .spyderproject
1041
+ .spyproject
1042
+
1043
+ # Rope project settings
1044
+ .ropeproject
1045
+
1046
+ # mkdocs documentation
1047
+ /site
1048
+
1049
+ # mypy
1050
+ .mypy_cache/
1051
+ .dmypy.json
1052
+ dmypy.json
1053
+
1054
+ # Pyre type checker
1055
+ .pyre/
1056
+
1057
+ # pytype static type analyzer
1058
+ .pytype/
1059
+
1060
+ # Cython debug symbols
1061
+ cython_debug/
1062
+
1063
+ ### Windows template
1064
+ # Windows thumbnail cache files
1065
+ Thumbs.db
1066
+ Thumbs.db:encryptable
1067
+ ehthumbs.db
1068
+ ehthumbs_vista.db
1069
+
1070
+ # Dump file
1071
+ *.stackdump
1072
+
1073
+ # Folder config file
1074
+ [Dd]esktop.ini
1075
+
1076
+ # Recycle Bin used on file shares
1077
+ $RECYCLE.BIN/
1078
+
1079
+ # Windows Installer files
1080
+ *.cab
1081
+ *.msi
1082
+ *.msix
1083
+ *.msm
1084
+ *.msp
1085
+
1086
+ # Windows shortcuts
1087
+ *.lnk
1088
+
1089
+ ### Xcode template
1090
+ # Xcode
1091
+ #
1092
+ # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
1093
+
1094
+ ## User settings
1095
+ xcuserdata/
1096
+
1097
+ ## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
1098
+ *.xcscmblueprint
1099
+ *.xccheckout
1100
+
1101
+ ## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
1102
+ build/
1103
+ DerivedData/
1104
+ *.moved-aside
1105
+ *.pbxuser
1106
+ !default.pbxuser
1107
+ *.mode1v3
1108
+ !default.mode1v3
1109
+ *.mode2v3
1110
+ !default.mode2v3
1111
+ *.perspectivev3
1112
+ !default.perspectivev3
1113
+
1114
+ ## Gcc Patch
1115
+ /*.gcno
1116
+
1117
+ ### JetBrains template
1118
+ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
1119
+ # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
1120
+
1121
+ # User-specific stuff
1122
+ .idea/**/workspace.xml
1123
+ .idea/**/tasks.xml
1124
+ .idea/**/usage.statistics.xml
1125
+ .idea/**/dictionaries
1126
+ .idea/**/shelf
1127
+
1128
+ # Generated files
1129
+ .idea/**/contentModel.xml
1130
+
1131
+ # Sensitive or high-churn files
1132
+ .idea/**/dataSources/
1133
+ .idea/**/dataSources.ids
1134
+ .idea/**/dataSources.local.xml
1135
+ .idea/**/sqlDataSources.xml
1136
+ .idea/**/dynamic.xml
1137
+ .idea/**/uiDesigner.xml
1138
+ .idea/**/dbnavigator.xml
1139
+
1140
+ # Gradle
1141
+ .idea/**/gradle.xml
1142
+ .idea/**/libraries
1143
+
1144
+ # Gradle and Maven with auto-import
1145
+ # When using Gradle or Maven with auto-import, you should exclude module files,
1146
+ # since they will be recreated, and may cause churn. Uncomment if using
1147
+ # auto-import.
1148
+ # .idea/artifacts
1149
+ # .idea/compiler.xml
1150
+ # .idea/jarRepositories.xml
1151
+ # .idea/modules.xml
1152
+ # .idea/*.iml
1153
+ # .idea/modules
1154
+ # *.iml
1155
+ # *.ipr
1156
+
1157
+ # CMake
1158
+ cmake-build-*/
1159
+
1160
+ # Mongo Explorer plugin
1161
+ .idea/**/mongoSettings.xml
1162
+
1163
+ # File-based project format
1164
+ *.iws
1165
+
1166
+ # IntelliJ
1167
+ out/
1168
+
1169
+ # mpeltonen/sbt-idea plugin
1170
+ .idea_modules/
1171
+
1172
+ # JIRA plugin
1173
+ atlassian-ide-plugin.xml
1174
+
1175
+ # Cursive Clojure plugin
1176
+ .idea/replstate.xml
1177
+
1178
+ # Crashlytics plugin (for Android Studio and IntelliJ)
1179
+ com_crashlytics_export_strings.xml
1180
+ crashlytics.properties
1181
+ crashlytics-build.properties
1182
+ fabric.properties
1183
+
1184
+ # Editor-based Rest Client
1185
+ .idea/httpRequests
1186
+
1187
+ # Android studio 3.1+ serialized cache file
1188
+ .idea/caches/build_file_checksums.ser
1189
+
1190
+ /test_*
1191
+ .python-version
1192
+ /docs/build
1193
+ /public
1194
+ /docs/source/**/*.puml.svg
1195
+ /docs/source/**/*.puml.png
1196
+ /docs/source/**/*.gv.svg
1197
+ /docs/source/**/*.gv.png
1198
+ /docs/source/**/*.py.txt
1199
+ /docs/source/**/*.py.err
1200
+ /docs/source/**/*.py.exitcode
1201
+ /docs/source/**/*.sh.txt
1202
+ /docs/source/**/*.sh.err
1203
+ /docs/source/**/*.sh.exitcode
1204
+ /docs/source/**/*.dat.*
1205
+ !/docs/source/_static/**/*
1206
+ /cartpole_dqn_*
1207
+ /extra
1208
+ /resource/yolort/*
1209
+ !/resource/yolort/Makefile
1210
+ /images
1211
+ /output
1212
+ /ckpt
1213
+ /ckpts
1214
+ /.benchmarks
1215
+ /onnxs
README.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Wd14 Tagging Online
3
+ emoji: 🚀
4
+ colorFrom: red
5
+ colorTo: indigo
6
+ sdk: gradio
7
+ sdk_version: 3.16.1
8
+ app_file: app.py
9
+ pinned: false
10
+ license: mit
11
+ duplicated_from: deepghs/wd14_tagging_online
12
+ ---
13
+
14
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import re
3
+ from typing import Mapping, Tuple, Dict
4
+
5
+ import cv2
6
+ import gradio as gr
7
+ import numpy as np
8
+ import pandas as pd
9
+ from PIL import Image
10
+ from huggingface_hub import hf_hub_download
11
+ from onnxruntime import InferenceSession
12
+
13
+
14
+ # noinspection PyUnresolvedReferences
15
+ def make_square(img, target_size):
16
+ old_size = img.shape[:2]
17
+ desired_size = max(old_size)
18
+ desired_size = max(desired_size, target_size)
19
+
20
+ delta_w = desired_size - old_size[1]
21
+ delta_h = desired_size - old_size[0]
22
+ top, bottom = delta_h // 2, delta_h - (delta_h // 2)
23
+ left, right = delta_w // 2, delta_w - (delta_w // 2)
24
+
25
+ color = [255, 255, 255]
26
+ return cv2.copyMakeBorder(img, top, bottom, left, right, cv2.BORDER_CONSTANT, value=color)
27
+
28
+
29
+ # noinspection PyUnresolvedReferences
30
+ def smart_resize(img, size):
31
+ # Assumes the image has already gone through make_square
32
+ if img.shape[0] > size:
33
+ img = cv2.resize(img, (size, size), interpolation=cv2.INTER_AREA)
34
+ elif img.shape[0] < size:
35
+ img = cv2.resize(img, (size, size), interpolation=cv2.INTER_CUBIC)
36
+ else: # just do nothing
37
+ pass
38
+
39
+ return img
40
+
41
+
42
+ class WaifuDiffusionInterrogator:
43
+ def __init__(
44
+ self,
45
+ repo='SmilingWolf/wd-v1-4-vit-tagger',
46
+ model_path='model.onnx',
47
+ tags_path='selected_tags.csv',
48
+ mode: str = "auto"
49
+ ) -> None:
50
+ self.__repo = repo
51
+ self.__model_path = model_path
52
+ self.__tags_path = tags_path
53
+ self._provider_mode = mode
54
+
55
+ self.__initialized = False
56
+ self._model, self._tags = None, None
57
+
58
+ def _init(self) -> None:
59
+ if self.__initialized:
60
+ return
61
+
62
+ model_path = hf_hub_download(self.__repo, filename=self.__model_path)
63
+ tags_path = hf_hub_download(self.__repo, filename=self.__tags_path)
64
+
65
+ self._model = InferenceSession(str(model_path))
66
+ self._tags = pd.read_csv(tags_path)
67
+
68
+ self.__initialized = True
69
+
70
+ def _calculation(self, image: Image.Image) -> pd.DataFrame:
71
+ self._init()
72
+
73
+ # code for converting the image and running the model is taken from the link below
74
+ # thanks, SmilingWolf!
75
+ # https://huggingface.co/spaces/SmilingWolf/wd-v1-4-tags/blob/main/app.py
76
+
77
+ # convert an image to fit the model
78
+ _, height, _, _ = self._model.get_inputs()[0].shape
79
+
80
+ # alpha to white
81
+ image = image.convert('RGBA')
82
+ new_image = Image.new('RGBA', image.size, 'WHITE')
83
+ new_image.paste(image, mask=image)
84
+ image = new_image.convert('RGB')
85
+ image = np.asarray(image)
86
+
87
+ # PIL RGB to OpenCV BGR
88
+ image = image[:, :, ::-1]
89
+
90
+ image = make_square(image, height)
91
+ image = smart_resize(image, height)
92
+ image = image.astype(np.float32)
93
+ image = np.expand_dims(image, 0)
94
+
95
+ # evaluate model
96
+ input_name = self._model.get_inputs()[0].name
97
+ label_name = self._model.get_outputs()[0].name
98
+ confidence = self._model.run([label_name], {input_name: image})[0]
99
+
100
+ full_tags = self._tags[['name', 'category']].copy()
101
+ full_tags['confidence'] = confidence[0]
102
+
103
+ return full_tags
104
+
105
+ def interrogate(self, image: Image) -> Tuple[Dict[str, float], Dict[str, float]]:
106
+ full_tags = self._calculation(image)
107
+
108
+ # first 4 items are for rating (general, sensitive, questionable, explicit)
109
+ ratings = dict(full_tags[full_tags['category'] == 9][['name', 'confidence']].values)
110
+
111
+ # rest are regular tags
112
+ tags = dict(full_tags[full_tags['category'] != 9][['name', 'confidence']].values)
113
+
114
+ return ratings, tags
115
+
116
+
117
+ WAIFU_MODELS: Mapping[str, WaifuDiffusionInterrogator] = {
118
+ 'wd14-vit': WaifuDiffusionInterrogator(),
119
+ 'wd14-convnext': WaifuDiffusionInterrogator(
120
+ repo='SmilingWolf/wd-v1-4-convnext-tagger'
121
+ ),
122
+ }
123
+ RE_SPECIAL = re.compile(r'([\\()])')
124
+
125
+
126
+ def image_to_wd14_tags(image: Image.Image, model_name: str, threshold: float,
127
+ use_spaces: bool, use_escape: bool, include_ranks: bool, score_descend: bool) \
128
+ -> Tuple[Mapping[str, float], str, Mapping[str, float]]:
129
+ model = WAIFU_MODELS[model_name]
130
+ ratings, tags = model.interrogate(image)
131
+
132
+ filtered_tags = {
133
+ tag: score for tag, score in tags.items()
134
+ if score >= threshold
135
+ }
136
+
137
+ text_items = []
138
+ tags_pairs = filtered_tags.items()
139
+ if score_descend:
140
+ tags_pairs = sorted(tags_pairs, key=lambda x: (-x[1], x[0]))
141
+ for tag, score in tags_pairs:
142
+ tag_outformat = tag
143
+ if use_spaces:
144
+ tag_outformat = tag_outformat.replace('_', ' ')
145
+ if use_escape:
146
+ tag_outformat = re.sub(RE_SPECIAL, r'\\\1', tag_outformat)
147
+ if include_ranks:
148
+ tag_outformat = f"({tag_outformat}:{score:.3f})"
149
+ text_items.append(tag_outformat)
150
+ output_text = ', '.join(text_items)
151
+
152
+ return ratings, output_text, filtered_tags
153
+
154
+
155
+ if __name__ == '__main__':
156
+ with gr.Blocks() as demo:
157
+ with gr.Row():
158
+ with gr.Column():
159
+ gr_input_image = gr.Image(type='pil', label='Original Image')
160
+ with gr.Row():
161
+ gr_model = gr.Radio(list(WAIFU_MODELS.keys()), value='wd14-vit', label='Waifu Model')
162
+ gr_threshold = gr.Slider(0.0, 1.0, 0.5, label='Tagging Confidence Threshold')
163
+ with gr.Row():
164
+ gr_space = gr.Checkbox(value=False, label='Use Space Instead Of _')
165
+ gr_escape = gr.Checkbox(value=True, label='Use Text Escape')
166
+ gr_confidence = gr.Checkbox(value=False, label='Keep Confidences')
167
+ gr_order = gr.Checkbox(value=True, label='Descend By Confidence')
168
+
169
+ gr_btn_submit = gr.Button(value='Tagging', variant='primary')
170
+
171
+ with gr.Column():
172
+ gr_ratings = gr.Label(label='Ratings')
173
+ with gr.Tabs():
174
+ with gr.Tab("Tags"):
175
+ gr_tags = gr.Label(label='Tags')
176
+ with gr.Tab("Exported Text"):
177
+ gr_output_text = gr.TextArea(label='Exported Text')
178
+
179
+ gr_btn_submit.click(
180
+ image_to_wd14_tags,
181
+ inputs=[gr_input_image, gr_model, gr_threshold, gr_space, gr_escape, gr_confidence, gr_order],
182
+ outputs=[gr_ratings, gr_output_text, gr_tags],
183
+ )
184
+ demo.queue(os.cpu_count()).launch()
requirements.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ gradio==3.16.1
2
+ numpy
3
+ pillow
4
+ onnxruntime
5
+ huggingface_hub
6
+ scikit-image
7
+ pandas
8
+ opencv-python>=4.6.0