narugo1992 commited on
Commit
90b4364
1 Parent(s): 99ddb06

dev(narugo): add first version

Browse files
Files changed (7) hide show
  1. .gitignore +1216 -0
  2. app.py +34 -0
  3. face.py +38 -0
  4. onnx_.py +59 -0
  5. plot.py +36 -0
  6. requirements.txt +11 -0
  7. yolo_.py +106 -0
.gitignore ADDED
@@ -0,0 +1,1216 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
1216
+ /.temp
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+
3
+ import gradio as gr
4
+
5
+ from face import _FACE_MODELS, _DEFAULT_FACE_MODEL, _gr_detect_faces
6
+
7
+ if __name__ == '__main__':
8
+ with gr.Blocks() as demo:
9
+ with gr.Tabs():
10
+ with gr.Tab('Face Detection'):
11
+ with gr.Row():
12
+ with gr.Column():
13
+ gr_face_input_image = gr.Image(type='pil', label='Original Image')
14
+ gr_face_model = gr.Dropdown(_FACE_MODELS, value=_DEFAULT_FACE_MODEL, label='Model')
15
+ gr_face_infer_size = gr.Slider(480, 1600, value=1216, step=32, label='Max Infer Size')
16
+ with gr.Row():
17
+ gr_face_iou_threshold = gr.Slider(0.0, 1.0, 0.7, label='IOU Threshold')
18
+ gr_face_score_threshold = gr.Slider(0.0, 1.0, 0.25, label='Score Threshold')
19
+
20
+ gr_face_submit = gr.Button(value='Submit', variant='primary')
21
+
22
+ with gr.Column():
23
+ gr_face_output_image = gr.Image(type='pil', label="Labeled")
24
+
25
+ gr_face_submit.click(
26
+ _gr_detect_faces,
27
+ inputs=[
28
+ gr_face_input_image, gr_face_model,
29
+ gr_face_infer_size, gr_face_score_threshold, gr_face_iou_threshold,
30
+ ],
31
+ outputs=[gr_face_output_image],
32
+ )
33
+
34
+ demo.queue(os.cpu_count()).launch()
face.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from functools import lru_cache
2
+
3
+ from huggingface_hub import hf_hub_download
4
+ from imgutils.data import ImageTyping, load_image, rgb_encode
5
+
6
+ from onnx_ import _open_onnx_model
7
+ from plot import plot_detection
8
+ from yolo_ import _image_preprocess, _data_simple_postprocess
9
+
10
+ _FACE_MODELS = [
11
+ 'face_detect_best_s.onnx',
12
+ ]
13
+ _DEFAULT_FACE_MODEL = _FACE_MODELS[0]
14
+
15
+
16
+ @lru_cache()
17
+ def _open_face_detect_model(model_name):
18
+ return _open_onnx_model(hf_hub_download(
19
+ 'deepghs/imgutils-models',
20
+ f'face_detect/{model_name}'
21
+ ))
22
+
23
+
24
+ def detect_faces(image: ImageTyping, model_name: str, max_infer_size=1216,
25
+ conf_threshold: float = 0.25, iou_threshold: float = 0.7):
26
+ image = load_image(image, mode='RGB')
27
+ new_image, old_size, new_size = _image_preprocess(image, max_infer_size)
28
+
29
+ data = rgb_encode(new_image)[None, ...]
30
+ output, = _open_face_detect_model(model_name).run(['output0'], {'images': data})
31
+ return _data_simple_postprocess(output[0], conf_threshold, iou_threshold, old_size, new_size)
32
+
33
+
34
+ def _gr_detect_faces(image: ImageTyping, model_name: str, max_infer_size=1216,
35
+ conf_threshold: float = 0.25, iou_threshold: float = 0.7):
36
+ ret = detect_faces(image, model_name, max_infer_size, conf_threshold, iou_threshold)
37
+ detections = [(box, 0, score) for box, score in ret]
38
+ return plot_detection(image, detections, ['head'])
onnx_.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import logging
2
+ import os
3
+ import shutil
4
+ from functools import lru_cache
5
+ from typing import Optional
6
+
7
+ from hbutils.system import pip_install
8
+
9
+
10
+ def _ensure_onnxruntime():
11
+ try:
12
+ import onnxruntime
13
+ except (ImportError, ModuleNotFoundError):
14
+ logging.warning('Onnx runtime not installed, preparing to install ...')
15
+ if shutil.which('nvidia-smi'):
16
+ logging.info('Installing onnxruntime-gpu ...')
17
+ pip_install(['onnxruntime-gpu'], silent=True)
18
+ else:
19
+ logging.info('Installing onnxruntime (cpu) ...')
20
+ pip_install(['onnxruntime'], silent=True)
21
+
22
+
23
+ _ensure_onnxruntime()
24
+ from onnxruntime import get_available_providers, get_all_providers, InferenceSession, SessionOptions, \
25
+ GraphOptimizationLevel
26
+
27
+ alias = {
28
+ 'gpu': "CUDAExecutionProvider",
29
+ "trt": "TensorrtExecutionProvider",
30
+ }
31
+
32
+
33
+ def get_onnx_provider(provider: Optional[str] = None):
34
+ if not provider:
35
+ if "CUDAExecutionProvider" in get_available_providers():
36
+ return "CUDAExecutionProvider"
37
+ else:
38
+ return "CPUExecutionProvider"
39
+ elif provider.lower() in alias:
40
+ return alias[provider.lower()]
41
+ else:
42
+ for p in get_all_providers():
43
+ if provider.lower() == p.lower() or f'{provider}ExecutionProvider'.lower() == p.lower():
44
+ return p
45
+
46
+ raise ValueError(f'One of the {get_all_providers()!r} expected, '
47
+ f'but unsupported provider {provider!r} found.')
48
+
49
+
50
+ @lru_cache()
51
+ def _open_onnx_model(ckpt: str, provider: str = None) -> InferenceSession:
52
+ options = SessionOptions()
53
+ options.graph_optimization_level = GraphOptimizationLevel.ORT_ENABLE_ALL
54
+ provider = provider or get_onnx_provider()
55
+ if provider == "CPUExecutionProvider":
56
+ options.intra_op_num_threads = os.cpu_count()
57
+
58
+ logging.info(f'Model {ckpt!r} loaded with provider {provider!r}')
59
+ return InferenceSession(ckpt, options, [provider])
plot.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import List, Tuple
2
+
3
+ from PIL import Image, ImageFont, ImageDraw
4
+ from hbutils.color import rnd_colors, Color
5
+
6
+
7
+ def plot_detection(pil_img: Image.Image, detection: List[Tuple[Tuple[float, float, float, float], int, float]],
8
+ captions: List[str], text_padding: int = 5, font: ImageFont.ImageFont = None,
9
+ no_label: bool = False):
10
+ new_img = pil_img.copy()
11
+ draw = ImageDraw.Draw(new_img, mode='RGBA')
12
+
13
+ _colors = list(map(str, rnd_colors(len(captions))))
14
+ _caption_map = {i: name for i, name in enumerate(captions)}
15
+ for (xmin, ymin, xmax, ymax), label, score in detection:
16
+ box_color = _colors[label]
17
+ draw.rectangle((xmin, ymin, xmax, ymax), outline=box_color, width=2)
18
+
19
+ if not no_label:
20
+ label_text = _caption_map.get(label, str(label))
21
+ label_text = f'{label_text}: {score * 100:.2f}%'
22
+
23
+ font = font or ImageFont.load_default()
24
+ _t_x0, _t_y0, _t_x1, _t_y1 = draw.textbbox((xmin, ymin), label_text, font=font)
25
+ _t_width, _t_height = _t_x1 - _t_x0, _t_y1 - _t_y0
26
+ if ymin - _t_height - text_padding < 0:
27
+ _t_text_rect = (xmin, ymin, xmin + _t_width + text_padding * 2, ymin + _t_height + text_padding * 2)
28
+ _t_text_co = (xmin + text_padding, ymin + text_padding)
29
+ else:
30
+ _t_text_rect = (xmin, ymin - _t_height - text_padding * 2, xmin + _t_width + text_padding * 2, ymin)
31
+ _t_text_co = (xmin + text_padding, ymin - _t_height - text_padding)
32
+
33
+ draw.rectangle(_t_text_rect, fill=str(Color(box_color, alpha=0.5)))
34
+ draw.text(_t_text_co, label_text, fill="black", font=font)
35
+
36
+ return new_img
requirements.txt ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ gradio==3.18.0
2
+ numpy
3
+ pillow
4
+ onnxruntime
5
+ huggingface_hub
6
+ scikit-image
7
+ pandas
8
+ opencv-python>=4.6.0
9
+ hbutils>=0.9.0
10
+ dghs-imgutils>=0.0.1
11
+ httpx==0.23.0
yolo_.py ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import math
2
+ from typing import List
3
+
4
+ import numpy as np
5
+ from PIL import Image
6
+
7
+
8
+ def _yolo_xywh2xyxy(x: np.ndarray) -> np.ndarray:
9
+ """
10
+ Copied from yolov8.
11
+
12
+ Convert bounding box coordinates from (x, y, width, height) format to (x1, y1, x2, y2) format where (x1, y1) is the
13
+ top-left corner and (x2, y2) is the bottom-right corner.
14
+
15
+ Args:
16
+ x (np.ndarray) or (torch.Tensor): The input bounding box coordinates in (x, y, width, height) format.
17
+ Returns:
18
+ y (np.ndarray) or (torch.Tensor): The bounding box coordinates in (x1, y1, x2, y2) format.
19
+ """
20
+ y = np.copy(x)
21
+ y[..., 0] = x[..., 0] - x[..., 2] / 2 # top left x
22
+ y[..., 1] = x[..., 1] - x[..., 3] / 2 # top left y
23
+ y[..., 2] = x[..., 0] + x[..., 2] / 2 # bottom right x
24
+ y[..., 3] = x[..., 1] + x[..., 3] / 2 # bottom right y
25
+ return y
26
+
27
+
28
+ def _yolo_nms(boxes, scores, thresh: float = 0.7) -> List[int]:
29
+ """
30
+ dets: ndarray, (num_boxes, 5)
31
+ 每一行表示一个bounding box:[xmin, ymin, xmax, ymax, score]
32
+ 其中xmin, ymin, xmax, ymax分别表示框的左上角和右下角坐标,score表示框的分数
33
+ thresh: float
34
+ 两个框的IoU阈值
35
+ """
36
+ x1 = boxes[:, 0]
37
+ y1 = boxes[:, 1]
38
+ x2 = boxes[:, 2]
39
+ y2 = boxes[:, 3]
40
+ areas = (x2 - x1 + 1) * (y2 - y1 + 1)
41
+
42
+ # 按照score降序排列
43
+ order = scores.argsort()[::-1]
44
+
45
+ keep = []
46
+ while order.size > 0:
47
+ i = order[0]
48
+ keep.append(i)
49
+ # 计算其他所有框与当前框的IoU
50
+ xx1 = np.maximum(x1[i], x1[order[1:]])
51
+ yy1 = np.maximum(y1[i], y1[order[1:]])
52
+ xx2 = np.minimum(x2[i], x2[order[1:]])
53
+ yy2 = np.minimum(y2[i], y2[order[1:]])
54
+
55
+ w = np.maximum(0.0, xx2 - xx1 + 1)
56
+ h = np.maximum(0.0, yy2 - yy1 + 1)
57
+
58
+ inter = w * h
59
+ iou = inter / (areas[i] + areas[order[1:]] - inter)
60
+
61
+ # 保留IoU小于阈值的框
62
+ inds = np.where(iou <= thresh)[0]
63
+ order = order[inds + 1]
64
+
65
+ return keep
66
+
67
+
68
+ def _image_preprocess(image: Image.Image, max_infer_size: int = 1216, align: int = 32):
69
+ old_width, old_height = image.width, image.height
70
+ new_width, new_height = old_width, old_height
71
+ r = max_infer_size / max(new_width, new_height)
72
+ if r < 1:
73
+ new_width, new_height = new_width * r, new_height * r
74
+ new_width = int(math.ceil(new_width / align) * align)
75
+ new_height = int(math.ceil(new_height / align) * align)
76
+ image = image.resize((new_width, new_height))
77
+ return image, (old_width, old_height), (new_width, new_height)
78
+
79
+
80
+ def _xy_postprocess(x, y, old_size, new_size):
81
+ old_width, old_height = old_size
82
+ new_width, new_height = new_size
83
+ x, y = x / new_width * old_width, y / new_height * old_height
84
+ x = int(np.clip(x, a_min=0, a_max=old_width).round())
85
+ y = int(np.clip(y, a_min=0, a_max=old_height).round())
86
+ return x, y
87
+
88
+
89
+ def _data_simple_postprocess(output, conf_threshold, iou_threshold, old_size, new_size):
90
+ output = output[:, output[-1, :] > conf_threshold]
91
+ boxes = output[:4, :].transpose(1, 0)
92
+ scores = output[4, :]
93
+ records = sorted(zip(boxes, scores), key=lambda x: -x[1])
94
+
95
+ boxes = _yolo_xywh2xyxy(np.stack([bx for bx, _ in records]))
96
+ scores = np.stack([score for _, score in records])
97
+ idx = _yolo_nms(boxes, scores, thresh=iou_threshold)
98
+ boxes, scores = boxes[idx], scores[idx]
99
+
100
+ detections = []
101
+ for box, score in zip(boxes, scores):
102
+ x0, y0 = _xy_postprocess(box[0], box[1], old_size, new_size)
103
+ x1, y1 = _xy_postprocess(box[2], box[3], old_size, new_size)
104
+ detections.append(((x0, y0, x1, y1), float(score)))
105
+
106
+ return detections