Glenn Jocher
3883261143
New `DetectMultiBackend()` class ( #5549 )
* New `DetectMultiBackend()` class
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* pb to pt fix
* Cleanup
* explicit apply_classifier path
* Cleanup2
* Cleanup3
* Cleanup4
* Cleanup5
* Cleanup6
* val.py MultiBackend inference
* warmup fix
* to device fix
* pt fix
* device fix
* Val cleanup
* COCO128 URL to assets
* half fix
* detect fix
* detect fix 2
* remove half from DetectMultiBackend
* training half handling
* training half handling 2
* training half handling 3
* Cleanup
* Fix CI error
* Add torchscript _extra_files
* Add TorchScript
* Add CoreML
* CoreML cleanup
* New `DetectMultiBackend()` class
* pb to pt fix
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Cleanup
* explicit apply_classifier path
* Cleanup2
* Cleanup3
* Cleanup4
* Cleanup5
* Cleanup6
* val.py MultiBackend inference
* warmup fix
* to device fix
* pt fix
* device fix
* Val cleanup
* COCO128 URL to assets
* half fix
* detect fix
* detect fix 2
* remove half from DetectMultiBackend
* training half handling
* training half handling 2
* training half handling 3
* Cleanup
* Fix CI error
* Add torchscript _extra_files
* Add TorchScript
* Add CoreML
* CoreML cleanup
* revert default to pt
* Add Usage examples
* Cleanup val
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
3 years ago
Glenn Jocher
79bca2bf64
`LOGGER` consolidation ( #5569 )
* Logger consolidation
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
3 years ago
Glenn Jocher
3f64ad1760
Fix `save_one_box()` ( #5545 )
* Fix `save_one_box()`
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
3 years ago
Jirka Borovec
0155548384
precommit: isort ( #5493 )
* precommit: isort
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update isort config
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update name
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
3 years ago
Glenn Jocher
5866646cc8
Fix float zeros format ( #5491 )
* Fix float zeros format
* 255 to integer
3 years ago
Glenn Jocher
5d4258fac5
Fix MixConv2d() remove shortcut + apply depthwise ( #5410 )
3 years ago
Jirka Borovec
ed887b5976
Add pre-commit CI actions ( #4982 )
* define pre-commit
* add CI code
* configure
* apply pre-commit
* fstring
* apply MD
* pre-commit
* Update torch_utils.py
* Update print strings
* notes
* Cleanup code-format.yml
* Update setup.cfg
* Update .pre-commit-config.yaml
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
3 years ago
Glenn Jocher
9c31a66f5d
Update `AutoShape.forward()` model.classes example ( #5324 )
3 years ago
Jebastin Nadar
9d75e42f98
Refactor `Detect()` anchors for ONNX <> OpenCV DNN compatibility ( #4833 )
* refactor anchors and anchor_grid in Detect Layer
* fix CI failures by adding compatibility
* fix tf failure
* fix different devices errors
* Cleanup
* fix anchors overwriting issue
* better refactoring
* Remove self.anchor_grid shape check (redundant with self.grid check)
Also PEP8 / 120 line width
* Convert _make_grid() from static to dynamic method
* Remove anchor_grid.to(device)
clone() should already clone to same device as self.anchors
* fix different devices error
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
3 years ago
Jebastin Nadar
a0e15046c3
Fix different devices bug when moving model from GPU to CPU ( #5110 )
* fix different devices bug
* extend _apply() instead of to() for a general fix
* Only apply if Detect() is last layer
Co-authored-by: Jebastin Nadar <njebastin10@gmail.com>
* Indent fix
* Add comment to yolo.py
* Add comment to common.py
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
3 years ago
Glenn Jocher
a820b43aca
Automatic Chinese fonts plotting ( #4951 )
* Automatic Chinese fonts plotting
* Default PIL=False
3 years ago
Jean-Baptiste Martin
1cad0ce2c7
Allow `multi_label` option for NMS with PyTorch Hub ( #4728 )
* Allow specifying multi_label option for NMS when using torch hub
* Reformat
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
3 years ago
ELHoussineT
0d8a184237
Add `crops = results.crops()` dictionary ( #4676 )
* adding get cropped functionality
* Add target logic in existing functions
* Crops cleanup
* Add dictionary keys: conf, cls, box
* Bug fixes - avoid return after first image
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
3 years ago
Glenn Jocher
e5e5ebc799
Auto-UTF handling ( #4594 )
3 years ago
Glenn Jocher
de44376d1b
Create `Annotator()` class ( #4591 )
* Add Annotator() class
* Download Arial
* 2x for loop
* Cleanup
* tuple 2 list
* max_size=1920
* bold logging results to
* tolist()
* im = annotator.im
* PIL save in detect.py
* Smart asarray in detect.py
* revert to cv2.imwrite
* Cleanup
* Return result asarray
* Add `Profile()` profiler
* CamelCase Timeout
* Resize after mosaic
* pillow>=8.0.0
* daemon imwrite
* Add cv2 support
* Remove plot_wh_methods and plot_one_box
* pil=False for hubconf.py annotations
* im.shape bug fix
* colorstr common.py
* join daemons
* Update t.daemon
* Removed daemon saving
3 years ago
Glenn Jocher
01cdb7671b
Add `SPPF()` layer ( #4420 )
* Add `SPPF()` layer
* Cleanup
* Add credit
3 years ago
Glenn Jocher
24bea5e4b7
Standardize headers and docstrings ( #4417 )
* Implement new headers
* Reformat 1
* Reformat 2
* Reformat 3 - math
* Reformat 4 - yaml
3 years ago
Glenn Jocher
2da4e7acf7
Merge PIL and OpenCV in `plot_one_box(use_pil=False)` ( #4416 )
* Merge PIL and OpenCV box plotting functions
* Add ASCII check to plot_one_box
* Cleanup
* Cleanup2
3 years ago
Glenn Jocher
4e8c81a368
Add `yolov5s-ghost.yaml` ( #4412 )
* Add yolov5s-ghost.yaml
* Finish C3Ghost
* Add C3Ghost to list
* Add C3Ghost to number of repeats if statement
* Fixes
* Cleanup
3 years ago
Yonghye Kwon
e96c74b5a1
Simpler code for DWConvClass ( #4310 )
* more simpler code for DWConvClass
more simpler code for DWConvClass
* remove DWConv function
* Replace DWConvClass with DWConv
3 years ago
Glenn Jocher
587c4b4b81
Add `DWConvClass()` ( #4274 )
* Add `DWConvClass()`
* Cleanup
* Cleanup2
3 years ago
Glenn Jocher
9c6732f61c
Update variables ( #4273 )
3 years ago
Glenn Jocher
306fc0119a
Update Autoshape forward header ( #4271 )
3 years ago
Glenn Jocher
18f6ba77cf
Suppress torch 1.9.0 max_pool2d() warning ( #4227 )
3 years ago
Glenn Jocher
2683b18079
Update Hub Path inputs ( #4200 )
3 years ago
Glenn Jocher
b1be685005
Module `super().__init__()` ( #4065 )
* Module `super().__init__()`
* remove NMS
3 years ago
Glenn Jocher
f7d8562060
`val.py` refactor ( #4053 )
* val.py refactor
* cleanup
* cleanup
* cleanup
* cleanup
* save after eval
* opt.imgsz bug fix
* wandb refactor
* dataloader to train_loader
* capitalize global variables
* runs/hub/exp to runs/detect/exp
* refactor wandb logging
* Refactor wandb operations (#4061 )
Co-authored-by: Ayush Chaurasia <ayush.chaurarsia@gmail.com>
3 years ago
Glenn Jocher
9dd33fd20f
AutoShape PosixPath support ( #4047 )
* AutoShape PosixPath support
Usage example:
````python
from pathlib import Path
model = ...
file = Path('data/images/zidane.jpg')
results = model(file)
```
* Update common.py
3 years ago
Glenn Jocher
d204a61834
Alert (no detections) ( #3984 )
* `Detections()` class `print()` overload
* Update common.py
3 years ago
Glenn Jocher
b3dabdcc38
Update `probability` to `p` ( #3980 )
3 years ago
jmiranda-laplateforme
588094eb7a
Update `setattr()` default for Hub PIL images ( #3923 )
Fix inference from PIL source.
3 years ago
Glenn Jocher
3c3f8fbd5d
Improved BGR2RGB speeds ( #3880 )
* Update BGR2RGB ops
* speed improvements
* cleanup
3 years ago
Valentin Aliferov
831773f5a2
Add EXIF rotation to YOLOv5 Hub inference ( #3852 )
* rotating an image according to its exif tag
* Update common.py
* Update datasets.py
* Update datasets.py
faster
* delete extraneous gpg file
* Update common.py
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
3 years ago
Glenn Jocher
25d1f2932c
Plot `AutoShape()` detections in ascending order ( #3843 )
3 years ago
Glenn Jocher
57c5d02bbe
Concise `TransformerBlock()` ( #3821 )
3 years ago
Adrian Holovaty
3f74cd9ed1
Parameterize max_det + inference default at 1000 ( #3215 )
* Added max_det parameters in various places
* 120 character line
* PEP8
* 120 character line
* Update inference default to 1000 instances
* Update inference default to 1000 instances
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
3 years ago
Yonghye Kwon
be86c21c73
rename class autoShape -> AutoShape ( #3173 )
* rename class autoShape -> AutoShape
follow other class naming convention
* rename class autoShape -> AutoShape
follow other classes' naming convention
* rename class autoShape -> AutoShape
3 years ago
Glenn Jocher
57812df68c
New Colors() class ( #2963 )
3 years ago
Burhan
c949fc86d1
Detection cropping+saving feature addition for detect.py and PyTorch Hub ( #2827 )
* Update detect.py
* Update detect.py
* Update greetings.yml
* Update cropping
* cleanup
* Update increment_path()
* Update common.py
* Update detect.py
* Update detect.py
* Update detect.py
* Update common.py
* cleanup
* Update detect.py
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
3 years ago
Glenn Jocher
c15e25c40f
PyTorch Hub cv2 .save() .show() bug fix ( #2831 )
* PyTorch Hub cv2 .save() .show() bug fix
cv2.rectangle() was failing on non-contiguous np array inputs. This checks for contiguous arrays and applies is necessary:
```python
imgs[i] = im if im.data.contiguous else np.ascontiguousarray(im) # update
```
* Update plots.py
```python
assert im.data.contiguous, 'Image not contiguous. Apply np.ascontiguousarray(im) to plot_on_box() input image.'
```
* Update hubconf.py
Expand CI tests to OpenCV image.
3 years ago
Glenn Jocher
b5de52c4cd
torch.cuda.amp bug fix ( #2750 )
PR https://github.com/ultralytics/yolov5/pull/2725 introduced a very specific bug that only affects multi-GPU trainings. Apparently the cause was using the torch.cuda.amp decorator in the autoShape forward method. I've implemented amp more traditionally in this PR, and the bug is resolved.
3 years ago
Glenn Jocher
fca5e2a48f
autocast enable=torch.cuda.is_available() ( #2748 )
3 years ago
Glenn Jocher
c03d590320
Add Hub results.pandas() method ( #2725 )
* Add Hub results.pandas() method
New method converts results from torch tensors to pandas DataFrames with column names.
This PR may partially resolve issue https://github.com/ultralytics/yolov5/issues/2703
```python
results = model(imgs)
print(results.pandas().xyxy[0])
xmin ymin xmax ymax confidence class name
0 57.068970 391.770599 241.383545 905.797852 0.868964 0 person
1 667.661255 399.303589 810.000000 881.396667 0.851888 0 person
2 222.878387 414.774231 343.804474 857.825073 0.838376 0 person
3 4.205386 234.447678 803.739136 750.023376 0.658006 5 bus
4 0.000000 550.596008 76.681190 878.669922 0.450596 0 person
```
* Update comments
torch example input now shown resized to size=640 and also now a multiple of P6 stride 64 (see https://github.com/ultralytics/yolov5/issues/2722#issuecomment-814785930 )
* apply decorators
* PEP8
* Update common.py
* pd.options.display.max_columns = 10
* Update common.py
3 years ago
Glenn Jocher
ec8979f1d2
Updated filename attributes for YOLOv5 Hub BytesIO ( #2718 )
Fix 2 for 'Model predict with forward will fail if PIL image does not have filename attribute' #2702
3 years ago
Glenn Jocher
74276d5189
Updated filename attributes for YOLOv5 Hub results ( #2708 )
Proposed fix for 'Model predict with forward will fail if PIL image does not have filename attribute' #2702
3 years ago
Glenn Jocher
17300a4c7b
autoShape forward im = np.asarray(im) # to numpy ( #2689 )
Slight speedup.
3 years ago
Glenn Jocher
2af059c0d8
PyTorch Hub model.save() increment as runs/hub/exp ( #2684 )
* PyTorch Hub model.save() increment as runs/hub/exp
This chane will align PyTorch Hub results saving with the existing unified results saving directory structure of
runs/
/train
/detect
/test
/hub
/exp
/exp2
...
* cleanup
3 years ago
Ding Yiwei
1148e2ea63
Add TransformerLayer, TransformerBlock, C3TR modules ( #2333 )
* yolotr
* transformer block
* Remove bias in Transformer
* Remove C3T
* Remove a deprecated class
* put the 2nd LayerNorm into the 2nd residual block
* move example model to models/hub, rename to -transformer
* Add module comments and TODOs
* Remove LN in Transformer
* Add comments for Transformer
* Solve the problem of MA with DDP
* cleanup
* cleanup find_unused_parameters
* PEP8 reformat
Co-authored-by: DingYiwei <846414640@qq.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
3 years ago
Glenn Jocher
2bf34f50fd
PyTorch Hub amp.autocast() inference ( #2641 )
I think this should help speed up CUDA inference, as currently models may be running in FP32 inference mode on CUDA devices unnecesarily.
3 years ago
Glenn Jocher
005d7a8c54
Update Detections() self.n comment ( #2620 )
```python
self.n = len(self.pred) # number of images (batch size)
```
3 years ago