birder 0.2.2__py3-none-any.whl → 0.2.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. birder/common/lib.py +2 -9
  2. birder/common/training_cli.py +18 -0
  3. birder/common/training_utils.py +123 -10
  4. birder/data/collators/detection.py +10 -3
  5. birder/data/datasets/coco.py +8 -10
  6. birder/data/transforms/detection.py +30 -13
  7. birder/inference/detection.py +108 -4
  8. birder/inference/wbf.py +226 -0
  9. birder/net/__init__.py +8 -0
  10. birder/net/detection/efficientdet.py +65 -86
  11. birder/net/detection/rt_detr_v1.py +1 -0
  12. birder/net/detection/yolo_anchors.py +205 -0
  13. birder/net/detection/yolo_v2.py +25 -24
  14. birder/net/detection/yolo_v3.py +39 -40
  15. birder/net/detection/yolo_v4.py +28 -26
  16. birder/net/detection/yolo_v4_tiny.py +24 -20
  17. birder/net/fasternet.py +1 -1
  18. birder/net/gc_vit.py +671 -0
  19. birder/net/lit_v1.py +472 -0
  20. birder/net/lit_v1_tiny.py +342 -0
  21. birder/net/lit_v2.py +436 -0
  22. birder/net/mobilenet_v4_hybrid.py +1 -1
  23. birder/net/resnet_v1.py +1 -1
  24. birder/net/resnext.py +67 -25
  25. birder/net/se_resnet_v1.py +46 -0
  26. birder/net/se_resnext.py +3 -0
  27. birder/net/simple_vit.py +2 -2
  28. birder/net/vit.py +0 -15
  29. birder/net/vovnet_v2.py +31 -1
  30. birder/scripts/benchmark.py +90 -21
  31. birder/scripts/predict.py +1 -0
  32. birder/scripts/predict_detection.py +18 -11
  33. birder/scripts/train.py +10 -34
  34. birder/scripts/train_barlow_twins.py +10 -34
  35. birder/scripts/train_byol.py +10 -34
  36. birder/scripts/train_capi.py +10 -35
  37. birder/scripts/train_data2vec.py +9 -34
  38. birder/scripts/train_data2vec2.py +9 -34
  39. birder/scripts/train_detection.py +48 -40
  40. birder/scripts/train_dino_v1.py +10 -34
  41. birder/scripts/train_dino_v2.py +9 -34
  42. birder/scripts/train_dino_v2_dist.py +9 -34
  43. birder/scripts/train_franca.py +9 -34
  44. birder/scripts/train_i_jepa.py +9 -34
  45. birder/scripts/train_ibot.py +9 -34
  46. birder/scripts/train_kd.py +156 -64
  47. birder/scripts/train_mim.py +10 -34
  48. birder/scripts/train_mmcr.py +10 -34
  49. birder/scripts/train_rotnet.py +10 -34
  50. birder/scripts/train_simclr.py +10 -34
  51. birder/scripts/train_vicreg.py +10 -34
  52. birder/tools/auto_anchors.py +20 -1
  53. birder/tools/pack.py +172 -103
  54. birder/tools/show_det_iterator.py +10 -1
  55. birder/version.py +1 -1
  56. {birder-0.2.2.dist-info → birder-0.2.3.dist-info}/METADATA +3 -3
  57. {birder-0.2.2.dist-info → birder-0.2.3.dist-info}/RECORD +61 -55
  58. {birder-0.2.2.dist-info → birder-0.2.3.dist-info}/WHEEL +0 -0
  59. {birder-0.2.2.dist-info → birder-0.2.3.dist-info}/entry_points.txt +0 -0
  60. {birder-0.2.2.dist-info → birder-0.2.3.dist-info}/licenses/LICENSE +0 -0
  61. {birder-0.2.2.dist-info → birder-0.2.3.dist-info}/top_level.txt +0 -0
@@ -15,18 +15,13 @@ import torch
15
15
  from torch import nn
16
16
  from torchvision.ops import Conv2dNormActivation
17
17
 
18
+ from birder.model_registry import registry
18
19
  from birder.net.base import DetectorBackbone
20
+ from birder.net.detection.yolo_anchors import resolve_anchor_groups
19
21
  from birder.net.detection.yolo_v3 import YOLOAnchorGenerator
20
22
  from birder.net.detection.yolo_v3 import YOLOHead
21
- from birder.net.detection.yolo_v3 import scale_anchors
22
23
  from birder.net.detection.yolo_v4 import YOLO_v4
23
24
 
24
- # Default anchors from YOLO v4 Tiny (COCO)
25
- DEFAULT_ANCHORS = [
26
- [(10.0, 14.0), (23.0, 27.0), (37.0, 58.0)], # Medium
27
- [(81.0, 82.0), (135.0, 169.0), (344.0, 319.0)], # Large
28
- ]
29
-
30
25
  # Scale factors per detection scale to eliminate grid sensitivity
31
26
  DEFAULT_SCALE_XY = [1.05, 1.05] # [medium, large]
32
27
 
@@ -92,7 +87,6 @@ class YOLOTinyNeck(nn.Module):
92
87
  # pylint: disable=invalid-name
93
88
  class YOLO_v4_Tiny(YOLO_v4):
94
89
  default_size = (416, 416)
95
- auto_register = True
96
90
 
97
91
  def __init__(
98
92
  self,
@@ -104,22 +98,26 @@ class YOLO_v4_Tiny(YOLO_v4):
104
98
  export_mode: bool = False,
105
99
  ) -> None:
106
100
  super().__init__(num_classes, backbone, config=config, size=size, export_mode=export_mode)
107
- assert self.config is None, "config not supported"
101
+ assert self.config is not None, "must set config"
108
102
 
109
103
  # self.num_classes = self.num_classes - 1 (Subtracted at parent)
110
104
 
111
105
  score_thresh = 0.05
112
106
  nms_thresh = 0.45
113
107
  detections_per_img = 300
114
- self.ignore_thresh = 0.7
115
-
116
- # Loss coefficients
117
- self.noobj_coeff = 0.25
118
- self.coord_coeff = 3.0
119
- self.obj_coeff = 1.0
120
- self.cls_coeff = 1.0
121
-
122
- self.anchors = scale_anchors(DEFAULT_ANCHORS, self.default_size, self.size)
108
+ ignore_thresh = 0.7
109
+ noobj_coeff = 0.25
110
+ coord_coeff = 3.0
111
+ obj_coeff = 1.0
112
+ cls_coeff = 1.0
113
+ label_smoothing = 0.1
114
+ anchor_spec = self.config["anchors"]
115
+
116
+ self.ignore_thresh = ignore_thresh
117
+ self.noobj_coeff = noobj_coeff
118
+ self.coord_coeff = coord_coeff
119
+ self.obj_coeff = obj_coeff
120
+ self.cls_coeff = cls_coeff
123
121
  self.scale_xy = DEFAULT_SCALE_XY
124
122
  self.score_thresh = score_thresh
125
123
  self.nms_thresh = nms_thresh
@@ -128,12 +126,18 @@ class YOLO_v4_Tiny(YOLO_v4):
128
126
  self.backbone.return_channels = self.backbone.return_channels[-2:]
129
127
  self.backbone.return_stages = self.backbone.return_stages[-2:]
130
128
 
131
- self.label_smoothing = 0.1
129
+ self.label_smoothing = label_smoothing
132
130
  self.smooth_positive = 1.0 - self.label_smoothing
133
131
  self.smooth_negative = self.label_smoothing / self.num_classes
134
132
 
135
133
  self.neck = YOLOTinyNeck(self.backbone.return_channels)
136
134
 
137
- self.anchor_generator = YOLOAnchorGenerator(self.anchors)
135
+ anchors = resolve_anchor_groups(
136
+ anchor_spec, anchor_format="pixels", model_size=self.size, model_strides=(16, 32)
137
+ )
138
+ self.anchor_generator = YOLOAnchorGenerator(anchors)
138
139
  num_anchors = self.anchor_generator.num_anchors_per_location()
139
140
  self.head = YOLOHead(self.neck.out_channels, num_anchors, self.num_classes)
141
+
142
+
143
+ registry.register_model_config("yolo_v4_tiny", YOLO_v4_Tiny, config={"anchors": "yolo_v4_tiny"})
birder/net/fasternet.py CHANGED
@@ -6,7 +6,7 @@ Paper "Run, Don't Walk: Chasing Higher FLOPS for Faster Neural Networks",
6
6
  https://arxiv.org/abs/2303.03667
7
7
 
8
8
  Changes from original:
9
- * No extra norm's for detection
9
+ * No extra norms for detection
10
10
  """
11
11
 
12
12
  # Reference license: MIT