-
-
Notifications
You must be signed in to change notification settings - Fork 16.6k
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
New TensorFlow TFDWConv()
module
#7824
Conversation
@zldrobit this is my TF DWConv() implementation. Seems to work correctly. Tested with https://github.com/ultralytics/yolov5/releases/download/v6.1/yolov5s-dw.pt that has one layer converted to DWConv. |
@zldrobit I noticed that the TF Conv2d docs show a |
@zldrobit tests show a problem with TFDWConv(). To reproduce replace a few Conv() layers with DWConv() layers in yolov5s.yaml, i.e.: # Parameters
nc: 80 # number of classes
depth_multiple: 0.33 # model depth multiple
width_multiple: 0.50 # layer channel multiple
anchors:
- [10,13, 16,30, 33,23] # P3/8
- [30,61, 62,45, 59,119] # P4/16
- [116,90, 156,198, 373,326] # P5/32
# YOLOv5 v6.0 backbone
backbone:
# [from, number, module, args]
[[-1, 1, Conv, [64, 6, 2, 2]], # 0-P1/2
[-1, 1, Conv, [128, 3, 2]], # 1-P2/4
[-1, 3, C3, [128]],
[-1, 1, Conv, [256, 3, 2]], # 3-P3/8
[-1, 6, C3, [256]],
[-1, 1, Conv, [512, 3, 2]], # 5-P4/16
[-1, 9, C3, [512]],
[-1, 1, Conv, [1024, 3, 2]], # 7-P5/32
[-1, 3, C3, [1024]],
[-1, 1, SPPF, [1024, 5]], # 9
]
# YOLOv5 v6.0 head
head:
[[-1, 1, Conv, [512, 1, 1]],
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
[[-1, 6], 1, Concat, [1]], # cat backbone P4
[-1, 3, C3, [512, False]], # 13
[-1, 1, Conv, [256, 1, 1]],
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
[[-1, 4], 1, Concat, [1]], # cat backbone P3
[-1, 3, C3, [256, False]], # 17 (P3/8-small)
[-1, 1, DWConv, [256, 5, 2]],
[[-1, 14], 1, Concat, [1]], # cat head P4
[-1, 3, C3, [512, False]], # 20 (P4/16-medium)
[-1, 1, DWConv, [512, 5, 2]],
[[-1, 10], 1, Concat, [1]], # cat head P5
[-1, 3, C3, [1024, False]], # 23 (P5/32-large)
[[17, 20, 23], 1, Detect, [nc, anchors]], # Detect(P3, P4, P5)
] and then train a model and observe lower val mAP on TF exports. No errors. Not sure where the problem lies. EDIT: fixed in #7845 !python train.py --weights yolov5s.pt --cfg yolov5s.yaml --epochs 300
!python export.py --weights runs/train/exp/weights/best.pt --include saved_model
!python val.py --weights runs/train/exp/weights/best.pt
!python val.py --weights runs/train/exp/weights/best_saved_model |
* New TensorFlow `TFDWConv()` module Analog to DWConv() module: https://github.com/ultralytics/yolov5/blob/8aa2085a7e7ae20a17a7548edefbdb2960f2b29b/models/common.py#L53-L57 * Fix and new activations() function * Update tf.py
* New TensorFlow `TFDWConv()` module Analog to DWConv() module: https://github.com/ultralytics/yolov5/blob/8aa2085a7e7ae20a17a7548edefbdb2960f2b29b/models/common.py#L53-L57 * Fix and new activations() function * Update tf.py
Analog to DWConv() module
yolov5/models/common.py
Lines 53 to 57 in 8aa2085
🛠️ PR Summary
Made with ❤️ by Ultralytics Actions
🌟 Summary
Enhanced TensorFlow compatibility for YOLOv5 layers.
📊 Key Changes
Conv
andDepthwiseConv2D
layer parameter definitions for clarity and consistency.activations
function to map PyTorch activation functions to their TensorFlow equivalents.🎯 Purpose & Impact