Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to v5 2 #5

Merged
merged 765 commits into from
Sep 22, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
765 commits
Select commit Hold shift + click to select a range
e8c5237
ConfusionMatrix `normalize=True` fix (#3587)
glenn-jocher Jun 11, 2021
4984cf5
train.py GPU memory fix (#3590)
glenn-jocher Jun 11, 2021
53d4fc2
W&B: Allow changed in config variable #3588
AyushExel Jun 11, 2021
7a565f1
Update `dataset_stats()` (#3593)
glenn-jocher Jun 12, 2021
88b1945
Delete __init__.py (#3596)
glenn-jocher Jun 12, 2021
3133607
Simplify README.md (#3530)
kalenmike Jun 13, 2021
f8adee1
merge develop
glenn-jocher Jun 14, 2021
6062319
Update datasets.py (#3591)
masoodazhar Jun 14, 2021
239a11c
Download COCO and VOC by default (#3608)
glenn-jocher Jun 14, 2021
daab682
Suppress wandb images size mismatch warning (#3611)
AyushExel Jun 14, 2021
4c5d9bf
Fix incorrect end epoch comment (#3612)
wq9 Jun 15, 2021
7d3686a
Update `check_file()` (#3622)
glenn-jocher Jun 15, 2021
30e4c4f
Update README.md (#3624)
glenn-jocher Jun 15, 2021
de56813
FROM nvcr.io/nvidia/pytorch:21.05-py3 (#3633)
glenn-jocher Jun 16, 2021
65f81bf
Add `**/*.torchscript.pt` (#3634)
glenn-jocher Jun 16, 2021
6c0e1d9
Update `verify_image_label()` (#3635)
glenn-jocher Jun 16, 2021
bb79e13
RUN pip install --no-cache -U torch torchvision (#3637)
glenn-jocher Jun 16, 2021
d808855
Assert non-premature end of JPEG images (#3638)
xiaowk5516 Jun 16, 2021
3ce0db8
Update CONTRIBUTING.md (#3645)
glenn-jocher Jun 16, 2021
6187edc
Update CONTRIBUTING.md (#3647)
glenn-jocher Jun 16, 2021
fa29125
`is_coco` list fix (#3646)
thanhminhmr Jun 16, 2021
df7706d
Update README.md (#3650)
SpongeBab Jun 17, 2021
9b6dba6
Update `dataset_stats()` to list of dicts (#3657)
glenn-jocher Jun 17, 2021
2754ada
Remove `/weights` directory (#3659)
glenn-jocher Jun 17, 2021
ac34834
Update download_weights.sh comment (#3662)
glenn-jocher Jun 17, 2021
6d6e2ca
Update train.py (#3667)
glenn-jocher Jun 17, 2021
fa201f9
Update `train(hyp, *args)` to accept `hyp` file or dict (#3668)
glenn-jocher Jun 17, 2021
045d5d8
Update TensorBoard (#3669)
glenn-jocher Jun 17, 2021
2296f15
Update `WORLD_SIZE` and `RANK` retrieval (#3670)
glenn-jocher Jun 17, 2021
f527704
Cache v0.3: improved corrupt image/label reporting (#3676)
glenn-jocher Jun 18, 2021
2729761
EMA changes for pre-model's batch_size (#3681)
ZouJiu1 Jun 18, 2021
463628a
Update README.md (#3684)
glenn-jocher Jun 18, 2021
814806c
Update cache check (#3691)
glenn-jocher Jun 19, 2021
bf209f6
Skip HSV augmentation when hyperparameters are [0, 0, 0] (#3686)
thanhminhmr Jun 19, 2021
bfb2276
Slightly modify CLI execution (#3687)
lb-desupervised Jun 19, 2021
5bab9a2
Reformat (#3694)
glenn-jocher Jun 19, 2021
fad27c0
Update DDP for `torch.distributed.run` with `gloo` backend (#3680)
glenn-jocher Jun 19, 2021
b3e2f4e
Eliminate `total_batch_size` variable (#3697)
glenn-jocher Jun 19, 2021
c1af67d
Add torch DP warning (#3698)
glenn-jocher Jun 19, 2021
fbf41e0
Add `train.run()` method (#3700)
glenn-jocher Jun 20, 2021
e8810a5
Update DDP backend `if dist.is_nccl_available()` (#3705)
glenn-jocher Jun 20, 2021
75c0ff4
[x]W&B: Don't resume transfer learning runs (#3604)
AyushExel Jun 21, 2021
1f69d12
Update 4 main ops for paths and .run() (#3715)
glenn-jocher Jun 21, 2021
b83e1a4
Fix `img2label_paths()` order (#3720)
glenn-jocher Jun 21, 2021
0e2d0d5
Fix typo (#3729)
fcakyon Jun 22, 2021
9ac7d38
Backwards compatible cache version checks (#3730)
glenn-jocher Jun 22, 2021
dfc5a52
Merge remote-tracking branch 'upstream/master' into update-to-v5-2
robinmaillot Jun 22, 2021
3182e4b
Update readme.
robinmaillot Jun 22, 2021
6306091
Update `check_datasets()` for dynamic unzip path (#3732)
glenn-jocher Jun 22, 2021
fdc2239
Create `data/hyps` directory (#3747)
glenn-jocher Jun 23, 2021
ae4261c
Force non-zero hyp evolution weights `w` (#3748)
glenn-jocher Jun 23, 2021
417a2f4
Edit comment (#3759)
developer0hye Jun 24, 2021
f79d747
Add optional dataset.yaml `path` attribute (#3753)
glenn-jocher Jun 24, 2021
03281f8
COCO annotations JSON fix (#3764)
glenn-jocher Jun 24, 2021
3749573
Add `xyxy2xywhn()` (#3765)
developer0hye Jun 25, 2021
f2d97eb
Remove DDP MultiHeadAttention fix (#3768)
glenn-jocher Jun 25, 2021
09246a5
fix/incorrect_fitness_import (#3770)
SkalskiP Jun 25, 2021
ffb6e11
W&B: Update Tables API and comply with new dataset_check (#3772)
AyushExel Jun 25, 2021
f899417
NGA xView 2018 Dataset Auto-Download (#3775)
glenn-jocher Jun 25, 2021
9dc5d35
Update README.md fix banner width (#3785)
glenn-jocher Jun 26, 2021
157aa2f
Objectness IoU Sort (#3610)
glenn-jocher Jun 26, 2021
8035b61
Update objectness IoU sort (#3786)
glenn-jocher Jun 26, 2021
bd581b3
Create hyp.scratch-p6.yaml (#3787)
glenn-jocher Jun 26, 2021
8e7f285
Fix datasets for aws and get_coco.sh (#3788)
glenn-jocher Jun 26, 2021
92d49fd
Update seeds for single-GPU reproducibility (#3789)
glenn-jocher Jun 26, 2021
07166ba
Update Usage examples (#3790)
glenn-jocher Jun 26, 2021
96c87f1
nvcr.io/nvidia/pytorch:21.06-py3 (#3791)
glenn-jocher Jun 26, 2021
5e6886c
Update Dockerfile (#3792)
glenn-jocher Jun 26, 2021
47543f9
FROM nvcr.io/nvidia/pytorch:21.05-py3 (#3794)
glenn-jocher Jun 26, 2021
5e976a2
Fix competition link (#3799)
batrlatom Jun 27, 2021
3974d72
Fix warmup `accumulate` (#3722)
yellowdolphin Jun 28, 2021
20d45aa
Add feature map visualization (#3804)
Zigars Jun 28, 2021
02719dd
Update `feature_visualization()` (#3807)
glenn-jocher Jun 28, 2021
3213d87
Fix for `dataset_stats()` with updated data.yaml (#3819)
glenn-jocher Jun 29, 2021
5ea771d
Move IoU functions to metrics.py (#3820)
glenn-jocher Jun 29, 2021
57c5d02
Concise `TransformerBlock()` (#3821)
glenn-jocher Jun 29, 2021
00fcfb5
Update setup.py to use utf8 everywhere.
robinmaillot Jun 29, 2021
0e5b5cb
Update setup.py to use utf8 everywhere again.
robinmaillot Jun 29, 2021
7d6af69
Fix `LoadStreams()` dataloader frame skip issue (#3833)
feras-oughali Jun 30, 2021
25d1f29
Plot `AutoShape()` detections in ascending order (#3843)
glenn-jocher Jun 30, 2021
c6c88dc
Copy-Paste augmentation for YOLOv5 (#3845)
glenn-jocher Jun 30, 2021
b686338
Created using Colaboratory
glenn-jocher Jul 2, 2021
4717a3b
Created using Colaboratory
glenn-jocher Jul 2, 2021
831773f
Add EXIF rotation to YOLOv5 Hub inference (#3852)
vaaliferov Jul 2, 2021
d3e9d69
`--evolve 300` generations CLI argument (#3863)
san-soucie Jul 4, 2021
9d86b54
Add multi-stream saving feature (#3864)
ketan-b Jul 4, 2021
bd88e7f
Created using Colaboratory
glenn-jocher Jul 4, 2021
81b3182
Models `*.yaml` reformat (#3875)
glenn-jocher Jul 4, 2021
9e8fb9f
Create `utils/augmentations.py` (#3877)
glenn-jocher Jul 4, 2021
3c3f8fb
Improved BGR2RGB speeds (#3880)
glenn-jocher Jul 4, 2021
8930e22
Evolution commented `hyp['anchors']` fix (#3887)
glenn-jocher Jul 5, 2021
6a3ee7c
Hub models `map_location=device` (#3894)
glenn-jocher Jul 5, 2021
33202b7
YOLOv5 + Albumentations integration (#3882)
glenn-jocher Jul 5, 2021
61047a2
Save PyTorch Hub models to `/root/hub/cache/dir` (#3904)
johnohagan Jul 7, 2021
87b094b
Feature visualization update (#3920)
glenn-jocher Jul 7, 2021
411842e
Fix `torch.hub.list('ultralytics/yolov5')` pathlib bug (#3921)
glenn-jocher Jul 7, 2021
588094e
Update `setattr()` default for Hub PIL images (#3923)
jmiranda-laplateforme Jul 7, 2021
850970e
`feature_visualization()` CUDA fix (#3925)
glenn-jocher Jul 7, 2021
8c6f9e1
Update `dataset_stats()` for zipped datasets (#3926)
glenn-jocher Jul 8, 2021
e7888af
Fix inconsistent NMS IoU value for COCO (#3934)
eldarkurtic Jul 8, 2021
dabad57
Created using Colaboratory
glenn-jocher Jul 8, 2021
248504c
Feature visualization improvements 32 (#3947)
glenn-jocher Jul 9, 2021
a26e7de
Update augmentations.py (#3948)
glenn-jocher Jul 9, 2021
443af8b
Cache v0.4 update (#3954)
glenn-jocher Jul 10, 2021
80299a5
Numerical stability fix for Albumentations (#3958)
glenn-jocher Jul 10, 2021
8298ce5
Update `albumentations>=1.0.2` (#3966)
glenn-jocher Jul 11, 2021
90e60b4
Update `np.random.random()` to `random.random()` (#3967)
glenn-jocher Jul 11, 2021
a544d59
Update requirements.txt `albumentations>=1.0.2` (#3972)
glenn-jocher Jul 11, 2021
647223a
`Ensemble()` visualize fix (#3973)
seven320 Jul 11, 2021
41fdf9f
Created using Colaboratory
glenn-jocher Jul 12, 2021
b3dabdc
Update `probability` to `p` (#3980)
glenn-jocher Jul 12, 2021
d204a61
Alert (no detections) (#3984)
glenn-jocher Jul 12, 2021
8ee9fd1
Update README.md (#3996)
glenn-jocher Jul 13, 2021
720aaa6
Rename `test.py` to `val.py` (#4000)
glenn-jocher Jul 14, 2021
62409ee
W&B sweeps support (#3938)
AyushExel Jul 14, 2021
b7e985e
Update greetings.yml (#4024)
glenn-jocher Jul 16, 2021
951922c
Add `--sync-bn` known issue (#4032)
glenn-jocher Jul 17, 2021
0067d95
Update greetings.yml (#4037)
glenn-jocher Jul 17, 2021
dd62e2d
Update README.md (#4041)
glenn-jocher Jul 17, 2021
9dd33fd
AutoShape PosixPath support (#4047)
glenn-jocher Jul 18, 2021
f7d8562
`val.py` refactor (#4053)
glenn-jocher Jul 19, 2021
b1be685
Module `super().__init__()` (#4065)
glenn-jocher Jul 19, 2021
c8a98cb
Missing `nc` and `names` handling in check_dataset() (#4066)
glenn-jocher Jul 19, 2021
ee76a68
Created using Colaboratory
glenn-jocher Jul 19, 2021
7fdcc77
Albumentations >= 1.0.3 (#4068)
glenn-jocher Jul 19, 2021
0cc7c58
W&B: fix refactor bugs (#4069)
AyushExel Jul 19, 2021
442a7ab
Refactor `export.py` (#4080)
glenn-jocher Jul 20, 2021
3bef77f
Addition refactor `export.py` (#4089)
glenn-jocher Jul 20, 2021
2c073cd
Add train.py ``--img-size` floor (#4099)
glenn-jocher Jul 21, 2021
4bad914
Update resume.py (#4115)
glenn-jocher Jul 22, 2021
4495e00
Fix indentation in `log_training_progress()` (#4126)
imyhxy Jul 23, 2021
39ef6c7
Update README.md (#4134)
glenn-jocher Jul 24, 2021
2e53844
ONNX inference update (#4073)
glenn-jocher Jul 24, 2021
264be1a
Rename `opset_version` to `opset` (#4135)
glenn-jocher Jul 24, 2021
63dd65e
Update train.py (#4136)
glenn-jocher Jul 24, 2021
efe60b5
Refactor train.py and val.py `loggers` (#4137)
glenn-jocher Jul 24, 2021
d17b45e
Update README.md (#4143)
glenn-jocher Jul 24, 2021
6e4358f
Add `export.py` ONNX inference suggestion (#4146)
glenn-jocher Jul 25, 2021
3764277
Created using Colaboratory
glenn-jocher Jul 25, 2021
96e36a7
New CSV Logger (#4148)
glenn-jocher Jul 25, 2021
8acb573
Created using Colaboratory
glenn-jocher Jul 25, 2021
f8e1148
Update dataset headers (#4162)
glenn-jocher Jul 26, 2021
0ad6301
Update script headers (#4163)
glenn-jocher Jul 26, 2021
63a1971
Improve docstrings and run names (#4174)
AyushExel Jul 27, 2021
3fef117
Update comments header (#4184)
glenn-jocher Jul 27, 2021
5d66e48
Train from `--data path/to/dataset.zip` feature (#4185)
glenn-jocher Jul 28, 2021
a8d3d5e
Merge remote-tracking branch 'upstream/master' into update-to-v5-2
robinmaillot Jul 28, 2021
1f31b7c
Create yolov5-bifpn.yaml (#4195)
glenn-jocher Jul 28, 2021
2683b18
Update Hub Path inputs (#4200)
glenn-jocher Jul 28, 2021
e88e8f7
W&B: Restructure code to support the new dataset_check() feature (#4197)
AyushExel Jul 28, 2021
e016b15
Update yolov5-bifpn.yaml (#4208)
glenn-jocher Jul 28, 2021
750465e
W&B: More improvements and refactoring (#4205)
AyushExel Jul 28, 2021
b60b62e
PyCharm reformat (#4209)
glenn-jocher Jul 28, 2021
7820614
Add `@try_except` decorator (#4224)
glenn-jocher Jul 29, 2021
c2c958c
Explicit `requirements.txt` location (#4225)
glenn-jocher Jul 29, 2021
18f6ba7
Suppress torch 1.9.0 max_pool2d() warning (#4227)
glenn-jocher Jul 29, 2021
083c13d
Created using Colaboratory
glenn-jocher Jul 29, 2021
1a10b0e
Created using Colaboratory
glenn-jocher Jul 29, 2021
8d3c3ef
Fix weight decay comment (#4228)
glenn-jocher Jul 29, 2021
9468657
Update profiler (#4236)
glenn-jocher Jul 30, 2021
bceb57b
Add `python train.py --freeze N` argument (#4238)
IneovaAI Jul 30, 2021
d8f1883
Update `profile()` for CUDA Memory allocation (#4239)
glenn-jocher Jul 30, 2021
b74929c
Add `train.py` and `val.py` callbacks (#4220)
kalenmike Jul 31, 2021
cd540d8
W&B: suppress warnings (#4257)
AyushExel Aug 1, 2021
53bfcbe
Update AP calculation (#4260)
glenn-jocher Aug 1, 2021
306fc01
Update Autoshape forward header (#4271)
glenn-jocher Aug 2, 2021
9c6732f
Update variables (#4273)
glenn-jocher Aug 2, 2021
587c4b4
Add `DWConvClass()` (#4274)
glenn-jocher Aug 2, 2021
388016e
Update 'results saved to' string (#4275)
glenn-jocher Aug 2, 2021
621caea
W&B: Fix sweep bug (#4276)
AyushExel Aug 2, 2021
2d99063
Feature `python train.py --cache disk` (#4049)
junjihashimoto Aug 2, 2021
771ac6c
Fixed logging level in distributed mode (#4284)
imyhxy Aug 3, 2021
4103ce9
Simplify callbacks (#4289)
glenn-jocher Aug 4, 2021
e78aeac
Evolve in CSV format (#4307)
glenn-jocher Aug 4, 2021
86c7150
Update newline (#4308)
glenn-jocher Aug 4, 2021
f409d8e
Update README.md (#4309)
Justsubh01 Aug 4, 2021
e96c74b
Simpler code for DWConvClass (#4310)
developer0hye Aug 5, 2021
ce7deec
`int(mlc)` (#4385)
glenn-jocher Aug 11, 2021
e7fc274
Fix module count in parse_model (#4379)
orangeccc Aug 11, 2021
b27f69f
Created using Colaboratory
glenn-jocher Aug 11, 2021
11e4aeb
Update README.md (#4387)
glenn-jocher Aug 11, 2021
75d323d
W&B: Add advanced features tutorial (#4384)
AyushExel Aug 11, 2021
a4e4553
W&B: Fix for 4360 (#4388)
AyushExel Aug 11, 2021
3e7c59a
Fix rename `utils.google_utils` to `utils.downloads` (#4393)
glenn-jocher Aug 11, 2021
57c342a
Simplify ONNX inference command (#4405)
glenn-jocher Aug 13, 2021
d9f23ed
No cache option for reading datasets (#4376)
ahmadmustafaanis Aug 13, 2021
e086347
Update plots.py (#4407)
glenn-jocher Aug 14, 2021
4e8c81a
Add `yolov5s-ghost.yaml` (#4412)
glenn-jocher Aug 14, 2021
63e09fd
Remove `encoding='ascii'` (#4413)
glenn-jocher Aug 14, 2021
2da4e7a
Merge PIL and OpenCV in `plot_one_box(use_pil=False)` (#4416)
glenn-jocher Aug 14, 2021
bb0aed1
Created using Colaboratory
glenn-jocher Aug 14, 2021
24bea5e
Standardize headers and docstrings (#4417)
glenn-jocher Aug 14, 2021
01cdb76
Add `SPPF()` layer (#4420)
glenn-jocher Aug 15, 2021
4e65052
Created using Colaboratory
glenn-jocher Aug 15, 2021
19d03a9
Remove DDP process group timeout (#4422)
glenn-jocher Aug 15, 2021
dbc06ce
Update hubconf.py attempt_load import (#4428)
OmidSa75 Aug 16, 2021
f3e3f76
TFLite prep (#4436)
glenn-jocher Aug 16, 2021
808bcad
Add TensorFlow and TFLite export (#1127)
zldrobit Aug 17, 2021
6dd7dd8
Fix default `--weights yolov5s.pt` (#4458)
glenn-jocher Aug 17, 2021
1d65e81
Fix missing labels after albumentations (#4455)
huuquan1994 Aug 18, 2021
d1182c4
`check_requirements(('coremltools',))` (#4478)
glenn-jocher Aug 18, 2021
7316b78
W&B: Refactor the wandb_utils.py file (#4496)
AyushExel Aug 23, 2021
7b1643b
Add `install=True` argument to `check_requirements` (#4512)
glenn-jocher Aug 23, 2021
79af114
Automatic TFLite uint8 determination (#4515)
glenn-jocher Aug 23, 2021
2da6444
Fix for `python models/yolo.py --profile` (#4541)
glenn-jocher Aug 25, 2021
11f85e7
Auto-fix corrupt JPEGs (#4548)
glenn-jocher Aug 26, 2021
e899d6e
Fix for corrupt JPEGs auto-fix PR (#4560)
glenn-jocher Aug 27, 2021
8ac96b7
Fix for AP calculation limits 0.0 - 1.0 (#4563)
glenn-jocher Aug 27, 2021
8b18b66
ONNX opset 13 (#4566)
glenn-jocher Aug 27, 2021
93cc015
Add EarlyStopping feature (#4576)
glenn-jocher Aug 28, 2021
d7aa3f1
Remove `image_weights` DDP code (#4579)
glenn-jocher Aug 28, 2021
bbfafea
Add `Profile()` profiler (#4587)
glenn-jocher Aug 29, 2021
7b35971
Fix bug in `plot_one_box` when label is `None` (#4588)
karasawatakumi Aug 29, 2021
de44376
Create `Annotator()` class (#4591)
glenn-jocher Aug 29, 2021
e5e5ebc
Auto-UTF handling (#4594)
glenn-jocher Aug 29, 2021
dbbc6b5
Re-order `plots.py` to class-first (#4595)
glenn-jocher Aug 29, 2021
bfad364
Created using Colaboratory
glenn-jocher Aug 29, 2021
b894e69
Update mosaic plots font size (#4596)
glenn-jocher Aug 29, 2021
dc13820
TensorBoard `on_train_end()` speed improvements (#4605)
glenn-jocher Aug 30, 2021
bb4da08
Created using Colaboratory
glenn-jocher Aug 30, 2021
e7d1842
Auto-download Arial.ttf on init (#4606)
glenn-jocher Aug 30, 2021
35fe031
Fix: add P2 layer 21 to yolov5-p2.yaml `Detect()` inputs (#4608)
YukunXia Aug 30, 2021
3a72d4a
Update `check_git_status()` warning (#4610)
glenn-jocher Aug 30, 2021
11e7c7b
W&B: Don't log models in evolve operation (#4611)
AyushExel Aug 30, 2021
bb5ebc2
Close `matplotlib` plots after opening (#4612)
glenn-jocher Aug 30, 2021
50a9828
DDP `torch.jit.trace()` `--sync-bn` fix (#4615)
glenn-jocher Aug 30, 2021
ba0f808
Fix for Arial.ttf redownloads with hub inference (#4627)
glenn-jocher Aug 31, 2021
a4e8f78
Fix 2 for Arial.ttf redownloads with hub inference (#4628)
glenn-jocher Aug 31, 2021
de534e9
Fix 3 for Arial.ttf redownloads with hub inference (#4629)
glenn-jocher Aug 31, 2021
fda85a5
Checkpoint code.
robinmaillot Sep 1, 2021
234e8ae
Fix for `plot_evolve()` string argument (#4639)
glenn-jocher Sep 1, 2021
fad57c2
Fix `is_coco` on missing `data['val']` key (#4642)
glenn-jocher Sep 1, 2021
c610bc4
Fix workers to 1 for windows and fix issue with image_size not being …
robinmaillot Sep 2, 2021
730970b
Merge branch 'master' into modify_wandb
robinmaillot Sep 2, 2021
c0ee52e
Merge branch 'modify_wandb' into update-to-v5-2
robinmaillot Sep 2, 2021
aa2432f
Remove mojo files.
robinmaillot Sep 2, 2021
b20b128
Add mojo_test.py and update gitignore.
robinmaillot Sep 2, 2021
d16ac8f
Move entity and project to variables.
robinmaillot Sep 2, 2021
4e0abe6
Update installation of dependencies to only if needed and make whl se…
robinmaillot Sep 2, 2021
87fc7ff
Fix missing parameter in _find_module_wheel_path.
robinmaillot Sep 2, 2021
0195cbc
Remove extra prints.
robinmaillot Sep 3, 2021
c379794
Fix weights download bug and pretraining always using yolov5s weights.
robinmaillot Sep 3, 2021
4e5279e
Update code to work with Ultralytics YOLOv5:4 env.
robinmaillot Sep 3, 2021
8b16998
Add confidence threshold plot
vnoblet-nanovare Sep 14, 2021
c16dad8
Minor cleanup of azure_wrapper.
robinmaillot Sep 20, 2021
a114edc
Merge branch 'update-to-v5-2' of https://github.com/robin-maillot/yol…
vnoblet-nanovare Sep 20, 2021
1b9d689
Fix click/typer incompatibility before 4.0.0
robinmaillot Sep 20, 2021
066de6e
Merge branch 'update-to-v5-2' of https://github.com/robin-maillot/yol…
robinmaillot Sep 20, 2021
2c35fc5
Restore gitignore and remove wrong error import print in Azure wrapper.
robinmaillot Sep 21, 2021
de2e75c
Fix wrong typer version in requirements.
robinmaillot Sep 21, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add TensorFlow and TFLite export (ultralytics#1127)
* Add models/tf.py for TensorFlow and TFLite export

* Set auto=False for int8 calibration

* Update requirements.txt for TensorFlow and TFLite export

* Read anchors directly from PyTorch weights

* Add --tf-nms to append NMS in TensorFlow SavedModel and GraphDef export

* Remove check_anchor_order, check_file, set_logging from import

* Reformat code and optimize imports

* Autodownload model and check cfg

* update --source path, img-size to 320, single output

* Adjust representative_dataset

* Put representative dataset in tfl_int8 block

* detect.py TF inference

* weights to string

* weights to string

* cleanup tf.py

* Add --dynamic-batch-size

* Add xywh normalization to reduce calibration error

* Update requirements.txt

TensorFlow 2.3.1 -> 2.4.0 to avoid int8 quantization error

* Fix imports

Move C3 from models.experimental to models.common

* Add models/tf.py for TensorFlow and TFLite export

* Set auto=False for int8 calibration

* Update requirements.txt for TensorFlow and TFLite export

* Read anchors directly from PyTorch weights

* Add --tf-nms to append NMS in TensorFlow SavedModel and GraphDef export

* Remove check_anchor_order, check_file, set_logging from import

* Reformat code and optimize imports

* Autodownload model and check cfg

* update --source path, img-size to 320, single output

* Adjust representative_dataset

* detect.py TF inference

* Put representative dataset in tfl_int8 block

* weights to string

* weights to string

* cleanup tf.py

* Add --dynamic-batch-size

* Add xywh normalization to reduce calibration error

* Update requirements.txt

TensorFlow 2.3.1 -> 2.4.0 to avoid int8 quantization error

* Fix imports

Move C3 from models.experimental to models.common

* implement C3() and SiLU()

* Fix reshape dim to support dynamic batching

* Add epsilon argument in tf_BN, which is different between TF and PT

* Set stride to None if not using PyTorch, and do not warmup without PyTorch

* Add list support in check_img_size()

* Add list input support in detect.py

* sys.path.append('./') to run from yolov5/

* Add int8 quantization support for TensorFlow 2.5

* Add get_coco128.sh

* Remove --no-tfl-detect in models/tf.py (Use tf-android-tfl-detect branch for EdgeTPU)

* Update requirements.txt

* Replace torch.load() with attempt_load()

* Update requirements.txt

* Add --tf-raw-resize to set half_pixel_centers=False

* Add --agnostic-nms for TF class-agnostic NMS

* Cleanup after merge

* Cleanup2 after merge

* Cleanup3 after merge

* Add tf.py docstring with credit and usage

* pb saved_model and tflite use only one model in detect.py

* Add use cases in docstring of tf.py

* Remove redundant `stride` definition

* Remove keras direct import

* Fix `check_requirements(('tensorflow>=2.4.1',))`

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
  • Loading branch information
zldrobit and glenn-jocher authored Aug 17, 2021
commit 808bcad3bb952f4976aca63f95af8855bc227090
64 changes: 54 additions & 10 deletions detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from pathlib import Path

import cv2
import numpy as np
import torch
import torch.backends.cudnn as cudnn

Expand Down Expand Up @@ -51,6 +52,7 @@ def run(weights='yolov5s.pt', # model.pt path(s)
hide_labels=False, # hide labels
hide_conf=False, # hide confidences
half=False, # use FP16 half-precision inference
tfl_int8=False, # INT8 quantized TFLite model
):
save_img = not nosave and not source.endswith('.txt') # save inference images
webcam = source.isnumeric() or source.endswith('.txt') or source.lower().startswith(
Expand All @@ -68,7 +70,7 @@ def run(weights='yolov5s.pt', # model.pt path(s)
# Load model
w = weights[0] if isinstance(weights, list) else weights
classify, suffix = False, Path(w).suffix.lower()
pt, onnx, tflite, pb, graph_def = (suffix == x for x in ['.pt', '.onnx', '.tflite', '.pb', '']) # backend
pt, onnx, tflite, pb, saved_model = (suffix == x for x in ['.pt', '.onnx', '.tflite', '.pb', '']) # backend
stride, names = 64, [f'class{i}' for i in range(1000)] # assign defaults
if pt:
model = attempt_load(weights, map_location=device) # load FP32 model
Expand All @@ -83,30 +85,49 @@ def run(weights='yolov5s.pt', # model.pt path(s)
check_requirements(('onnx', 'onnxruntime'))
import onnxruntime
session = onnxruntime.InferenceSession(w, None)
else: # TensorFlow models
check_requirements(('tensorflow>=2.4.1',))
import tensorflow as tf
if pb: # https://www.tensorflow.org/guide/migrate#a_graphpb_or_graphpbtxt
def wrap_frozen_graph(gd, inputs, outputs):
x = tf.compat.v1.wrap_function(lambda: tf.compat.v1.import_graph_def(gd, name=""), []) # wrapped import
return x.prune(tf.nest.map_structure(x.graph.as_graph_element, inputs),
tf.nest.map_structure(x.graph.as_graph_element, outputs))

graph_def = tf.Graph().as_graph_def()
graph_def.ParseFromString(open(w, 'rb').read())
frozen_func = wrap_frozen_graph(gd=graph_def, inputs="x:0", outputs="Identity:0")
elif saved_model:
model = tf.keras.models.load_model(w)
elif tflite:
interpreter = tf.lite.Interpreter(model_path=w) # load TFLite model
interpreter.allocate_tensors() # allocate
input_details = interpreter.get_input_details() # inputs
output_details = interpreter.get_output_details() # outputs
imgsz = check_img_size(imgsz, s=stride) # check image size

# Dataloader
if webcam:
view_img = check_imshow()
cudnn.benchmark = True # set True to speed up constant image size inference
dataset = LoadStreams(source, img_size=imgsz, stride=stride)
dataset = LoadStreams(source, img_size=imgsz, stride=stride, auto=pt)
bs = len(dataset) # batch_size
else:
dataset = LoadImages(source, img_size=imgsz, stride=stride)
dataset = LoadImages(source, img_size=imgsz, stride=stride, auto=pt)
bs = 1 # batch_size
vid_path, vid_writer = [None] * bs, [None] * bs

# Run inference
if pt and device.type != 'cpu':
model(torch.zeros(1, 3, imgsz, imgsz).to(device).type_as(next(model.parameters()))) # run once
model(torch.zeros(1, 3, *imgsz).to(device).type_as(next(model.parameters()))) # run once
t0 = time.time()
for path, img, im0s, vid_cap in dataset:
if pt:
if onnx:
img = img.astype('float32')
else:
img = torch.from_numpy(img).to(device)
img = img.half() if half else img.float() # uint8 to fp16/32
elif onnx:
img = img.astype('float32')
img /= 255.0 # 0 - 255 to 0.0 - 1.0
img = img / 255.0 # 0 - 255 to 0.0 - 1.0
if len(img.shape) == 3:
img = img[None] # expand for batch dim

Expand All @@ -117,6 +138,27 @@ def run(weights='yolov5s.pt', # model.pt path(s)
pred = model(img, augment=augment, visualize=visualize)[0]
elif onnx:
pred = torch.tensor(session.run([session.get_outputs()[0].name], {session.get_inputs()[0].name: img}))
else: # tensorflow model (tflite, pb, saved_model)
imn = img.permute(0, 2, 3, 1).cpu().numpy() # image in numpy
if pb:
pred = frozen_func(x=tf.constant(imn)).numpy()
elif saved_model:
pred = model(imn, training=False).numpy()
elif tflite:
if tfl_int8:
scale, zero_point = input_details[0]['quantization']
imn = (imn / scale + zero_point).astype(np.uint8)
interpreter.set_tensor(input_details[0]['index'], imn)
interpreter.invoke()
pred = interpreter.get_tensor(output_details[0]['index'])
if tfl_int8:
scale, zero_point = output_details[0]['quantization']
pred = (pred.astype(np.float32) - zero_point) * scale
pred[..., 0] *= imgsz[1] # x
pred[..., 1] *= imgsz[0] # y
pred[..., 2] *= imgsz[1] # w
pred[..., 3] *= imgsz[0] # h
pred = torch.tensor(pred)

# NMS
pred = non_max_suppression(pred, conf_thres, iou_thres, classes, agnostic_nms, max_det=max_det)
Expand Down Expand Up @@ -202,9 +244,9 @@ def run(weights='yolov5s.pt', # model.pt path(s)

def parse_opt():
parser = argparse.ArgumentParser()
parser.add_argument('--weights', nargs='+', type=str, default='yolov5s.pt', help='model.pt path(s)')
parser.add_argument('--weights', nargs='+', type=str, default='yolov5s.pb', help='model.pt path(s)')
parser.add_argument('--source', type=str, default='data/images', help='file/dir/URL/glob, 0 for webcam')
parser.add_argument('--imgsz', '--img', '--img-size', type=int, default=640, help='inference size (pixels)')
parser.add_argument('--imgsz', '--img', '--img-size', nargs='+', type=int, default=[640], help='inference size h,w')
parser.add_argument('--conf-thres', type=float, default=0.25, help='confidence threshold')
parser.add_argument('--iou-thres', type=float, default=0.45, help='NMS IoU threshold')
parser.add_argument('--max-det', type=int, default=1000, help='maximum detections per image')
Expand All @@ -226,7 +268,9 @@ def parse_opt():
parser.add_argument('--hide-labels', default=False, action='store_true', help='hide labels')
parser.add_argument('--hide-conf', default=False, action='store_true', help='hide confidences')
parser.add_argument('--half', action='store_true', help='use FP16 half-precision inference')
parser.add_argument('--tfl-int8', action='store_true', help='INT8 quantized TFLite model')
opt = parser.parse_args()
opt.imgsz *= 2 if len(opt.imgsz) == 1 else 1 # expand
return opt


Expand Down
8 changes: 6 additions & 2 deletions models/experimental.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,18 @@ def forward(self, x, augment=False, profile=False, visualize=False):
return y, None # inference, train output


def attempt_load(weights, map_location=None, inplace=True):
def attempt_load(weights, map_location=None, inplace=True, fuse=True):
from models.yolo import Detect, Model

# Loads an ensemble of models weights=[a,b,c] or a single model weights=[a] or weights=a
model = Ensemble()
for w in weights if isinstance(weights, list) else [weights]:
ckpt = torch.load(attempt_download(w), map_location=map_location) # load
model.append(ckpt['ema' if ckpt.get('ema') else 'model'].float().fuse().eval()) # FP32 model
if fuse:
model.append(ckpt['ema' if ckpt.get('ema') else 'model'].float().fuse().eval()) # FP32 model
else:
model.append(ckpt['ema' if ckpt.get('ema') else 'model'].float().eval()) # without layer fuse


# Compatibility updates
for m in model.modules():
Expand Down
Loading