python-wml 3.0.0__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.

Potentially problematic release.


This version of python-wml might be problematic. Click here for more details.

Files changed (164) hide show
  1. python_wml-3.0.0.dist-info/LICENSE +23 -0
  2. python_wml-3.0.0.dist-info/METADATA +51 -0
  3. python_wml-3.0.0.dist-info/RECORD +164 -0
  4. python_wml-3.0.0.dist-info/WHEEL +5 -0
  5. python_wml-3.0.0.dist-info/top_level.txt +1 -0
  6. wml/__init__.py +0 -0
  7. wml/basic_data_def/__init__.py +2 -0
  8. wml/basic_data_def/detection_data_def.py +279 -0
  9. wml/basic_data_def/io_data_def.py +2 -0
  10. wml/basic_img_utils.py +816 -0
  11. wml/img_patch.py +92 -0
  12. wml/img_utils.py +571 -0
  13. wml/iotoolkit/__init__.py +17 -0
  14. wml/iotoolkit/aic_keypoint.py +115 -0
  15. wml/iotoolkit/baidu_mask_toolkit.py +244 -0
  16. wml/iotoolkit/base_dataset.py +210 -0
  17. wml/iotoolkit/bboxes_statistics.py +515 -0
  18. wml/iotoolkit/build.py +0 -0
  19. wml/iotoolkit/cityscapes_toolkit.py +183 -0
  20. wml/iotoolkit/classification_data_statistics.py +25 -0
  21. wml/iotoolkit/coco_data_fwd.py +225 -0
  22. wml/iotoolkit/coco_keypoints.py +118 -0
  23. wml/iotoolkit/coco_keypoints_fmt2.py +103 -0
  24. wml/iotoolkit/coco_toolkit.py +397 -0
  25. wml/iotoolkit/coco_wholebody.py +269 -0
  26. wml/iotoolkit/common.py +108 -0
  27. wml/iotoolkit/crowd_pose.py +146 -0
  28. wml/iotoolkit/fast_labelme.py +110 -0
  29. wml/iotoolkit/image_folder.py +95 -0
  30. wml/iotoolkit/imgs_cache.py +58 -0
  31. wml/iotoolkit/imgs_reader_mt.py +73 -0
  32. wml/iotoolkit/labelme_base.py +102 -0
  33. wml/iotoolkit/labelme_json_to_img.py +49 -0
  34. wml/iotoolkit/labelme_toolkit.py +117 -0
  35. wml/iotoolkit/labelme_toolkit_fwd.py +733 -0
  36. wml/iotoolkit/labelmemckeypoints_dataset.py +169 -0
  37. wml/iotoolkit/lspet.py +48 -0
  38. wml/iotoolkit/mapillary_vistas_toolkit.py +269 -0
  39. wml/iotoolkit/mat_data.py +90 -0
  40. wml/iotoolkit/mckeypoints_statistics.py +28 -0
  41. wml/iotoolkit/mot_datasets.py +62 -0
  42. wml/iotoolkit/mpii.py +108 -0
  43. wml/iotoolkit/npmckeypoints_dataset.py +164 -0
  44. wml/iotoolkit/o365_to_coco.py +136 -0
  45. wml/iotoolkit/object365_toolkit.py +156 -0
  46. wml/iotoolkit/object365v2_toolkit.py +71 -0
  47. wml/iotoolkit/pascal_voc_data.py +51 -0
  48. wml/iotoolkit/pascal_voc_toolkit.py +194 -0
  49. wml/iotoolkit/pascal_voc_toolkit_fwd.py +473 -0
  50. wml/iotoolkit/penn_action.py +57 -0
  51. wml/iotoolkit/rawframe_dataset.py +129 -0
  52. wml/iotoolkit/rewrite_pascal_voc.py +28 -0
  53. wml/iotoolkit/semantic_data.py +49 -0
  54. wml/iotoolkit/split_file_by_type.py +29 -0
  55. wml/iotoolkit/sports_mot_datasets.py +78 -0
  56. wml/iotoolkit/vis_objectdetection_dataset.py +70 -0
  57. wml/iotoolkit/vis_torch_data.py +39 -0
  58. wml/iotoolkit/yolo_toolkit.py +38 -0
  59. wml/object_detection2/__init__.py +4 -0
  60. wml/object_detection2/basic_visualization.py +37 -0
  61. wml/object_detection2/bboxes.py +812 -0
  62. wml/object_detection2/data_process_toolkit.py +146 -0
  63. wml/object_detection2/keypoints.py +292 -0
  64. wml/object_detection2/mask.py +120 -0
  65. wml/object_detection2/metrics/__init__.py +3 -0
  66. wml/object_detection2/metrics/build.py +15 -0
  67. wml/object_detection2/metrics/classifier_toolkit.py +440 -0
  68. wml/object_detection2/metrics/common.py +71 -0
  69. wml/object_detection2/metrics/mckps_toolkit.py +338 -0
  70. wml/object_detection2/metrics/toolkit.py +1953 -0
  71. wml/object_detection2/npod_toolkit.py +361 -0
  72. wml/object_detection2/odtools.py +243 -0
  73. wml/object_detection2/standard_names.py +75 -0
  74. wml/object_detection2/visualization.py +956 -0
  75. wml/object_detection2/wmath.py +34 -0
  76. wml/semantic/__init__.py +0 -0
  77. wml/semantic/basic_toolkit.py +65 -0
  78. wml/semantic/mask_utils.py +156 -0
  79. wml/semantic/semantic_test.py +21 -0
  80. wml/semantic/structures.py +1 -0
  81. wml/semantic/toolkit.py +105 -0
  82. wml/semantic/visualization_utils.py +658 -0
  83. wml/threadtoolkit.py +50 -0
  84. wml/walgorithm.py +228 -0
  85. wml/wcollections.py +212 -0
  86. wml/wfilesystem.py +487 -0
  87. wml/wml_utils.py +657 -0
  88. wml/wstructures/__init__.py +4 -0
  89. wml/wstructures/common.py +9 -0
  90. wml/wstructures/keypoints_train_toolkit.py +149 -0
  91. wml/wstructures/kps_structures.py +579 -0
  92. wml/wstructures/mask_structures.py +1161 -0
  93. wml/wtorch/__init__.py +8 -0
  94. wml/wtorch/bboxes.py +104 -0
  95. wml/wtorch/classes_suppression.py +24 -0
  96. wml/wtorch/conv_module.py +181 -0
  97. wml/wtorch/conv_ws.py +144 -0
  98. wml/wtorch/data/__init__.py +16 -0
  99. wml/wtorch/data/_utils/__init__.py +45 -0
  100. wml/wtorch/data/_utils/collate.py +183 -0
  101. wml/wtorch/data/_utils/fetch.py +47 -0
  102. wml/wtorch/data/_utils/pin_memory.py +121 -0
  103. wml/wtorch/data/_utils/signal_handling.py +72 -0
  104. wml/wtorch/data/_utils/worker.py +227 -0
  105. wml/wtorch/data/base_data_loader_iter.py +93 -0
  106. wml/wtorch/data/dataloader.py +501 -0
  107. wml/wtorch/data/datapipes/__init__.py +1 -0
  108. wml/wtorch/data/datapipes/iter/__init__.py +12 -0
  109. wml/wtorch/data/datapipes/iter/batch.py +126 -0
  110. wml/wtorch/data/datapipes/iter/callable.py +92 -0
  111. wml/wtorch/data/datapipes/iter/listdirfiles.py +37 -0
  112. wml/wtorch/data/datapipes/iter/loadfilesfromdisk.py +30 -0
  113. wml/wtorch/data/datapipes/iter/readfilesfromtar.py +60 -0
  114. wml/wtorch/data/datapipes/iter/readfilesfromzip.py +63 -0
  115. wml/wtorch/data/datapipes/iter/sampler.py +94 -0
  116. wml/wtorch/data/datapipes/utils/__init__.py +0 -0
  117. wml/wtorch/data/datapipes/utils/common.py +65 -0
  118. wml/wtorch/data/dataset.py +354 -0
  119. wml/wtorch/data/datasets/__init__.py +4 -0
  120. wml/wtorch/data/datasets/common.py +53 -0
  121. wml/wtorch/data/datasets/listdirfilesdataset.py +36 -0
  122. wml/wtorch/data/datasets/loadfilesfromdiskdataset.py +30 -0
  123. wml/wtorch/data/distributed.py +135 -0
  124. wml/wtorch/data/multi_processing_data_loader_iter.py +866 -0
  125. wml/wtorch/data/sampler.py +267 -0
  126. wml/wtorch/data/single_process_data_loader_iter.py +24 -0
  127. wml/wtorch/data/test_data_loader.py +26 -0
  128. wml/wtorch/dataset_toolkit.py +67 -0
  129. wml/wtorch/depthwise_separable_conv_module.py +98 -0
  130. wml/wtorch/dist.py +591 -0
  131. wml/wtorch/dropblock/__init__.py +6 -0
  132. wml/wtorch/dropblock/dropblock.py +228 -0
  133. wml/wtorch/dropblock/dropout.py +40 -0
  134. wml/wtorch/dropblock/scheduler.py +48 -0
  135. wml/wtorch/ema.py +61 -0
  136. wml/wtorch/fc_module.py +73 -0
  137. wml/wtorch/functional.py +34 -0
  138. wml/wtorch/iter_dataset.py +26 -0
  139. wml/wtorch/loss.py +69 -0
  140. wml/wtorch/nets/__init__.py +0 -0
  141. wml/wtorch/nets/ckpt_toolkit.py +219 -0
  142. wml/wtorch/nets/fpn.py +276 -0
  143. wml/wtorch/nets/hrnet/__init__.py +0 -0
  144. wml/wtorch/nets/hrnet/config.py +2 -0
  145. wml/wtorch/nets/hrnet/hrnet.py +494 -0
  146. wml/wtorch/nets/misc.py +249 -0
  147. wml/wtorch/nets/resnet/__init__.py +0 -0
  148. wml/wtorch/nets/resnet/layers/__init__.py +17 -0
  149. wml/wtorch/nets/resnet/layers/aspp.py +144 -0
  150. wml/wtorch/nets/resnet/layers/batch_norm.py +231 -0
  151. wml/wtorch/nets/resnet/layers/blocks.py +111 -0
  152. wml/wtorch/nets/resnet/layers/wrappers.py +110 -0
  153. wml/wtorch/nets/resnet/r50_config.py +38 -0
  154. wml/wtorch/nets/resnet/resnet.py +691 -0
  155. wml/wtorch/nets/shape_spec.py +20 -0
  156. wml/wtorch/nets/simple_fpn.py +101 -0
  157. wml/wtorch/nms.py +109 -0
  158. wml/wtorch/nn.py +896 -0
  159. wml/wtorch/ocr_block.py +193 -0
  160. wml/wtorch/summary.py +331 -0
  161. wml/wtorch/train_toolkit.py +603 -0
  162. wml/wtorch/transformer_blocks.py +266 -0
  163. wml/wtorch/utils.py +719 -0
  164. wml/wtorch/wlr_scheduler.py +100 -0
@@ -0,0 +1,149 @@
1
+ import numpy as np
2
+ from typing import Iterable
3
+ from .kps_structures import WMCKeypoints,WMCKeypointsItem
4
+
5
+ class HeatmapGenerator:
6
+ def __init__(self, output_res, num_joints, sigma=-1):
7
+ self.output_res = output_res
8
+ self.num_joints = num_joints
9
+ if sigma < 0:
10
+ sigma = self.output_res/64
11
+ self.sigma = sigma
12
+ size = 6*sigma + 3
13
+ x = np.arange(0, size, 1, float)
14
+ y = x[:, np.newaxis]
15
+ x0, y0 = 3*sigma + 1, 3*sigma + 1
16
+ self.g = np.exp(- ((x - x0) ** 2 + (y - y0) ** 2) / (2 * sigma ** 2))
17
+
18
+
19
+ def __call__(self, joints):
20
+ '''
21
+ joints: [max_num_people,num_joints,2] (x,y)
22
+ '''
23
+ hms = np.zeros((self.num_joints, self.output_res, self.output_res),
24
+ dtype=np.float32)
25
+ sigma = self.sigma
26
+ for p in joints:
27
+ for idx, pt in enumerate(p):
28
+ if pt[2] > 0:
29
+ x, y = int(pt[0]), int(pt[1])
30
+ if x < 0 or y < 0 or \
31
+ x >= self.output_res or y >= self.output_res:
32
+ continue
33
+
34
+ ul = int(np.round(x - 3 * sigma - 1)), int(np.round(y - 3 * sigma - 1))
35
+ br = int(np.round(x + 3 * sigma + 2)), int(np.round(y + 3 * sigma + 2))
36
+
37
+ c, d = max(0, -ul[0]), min(br[0], self.output_res) - ul[0]
38
+ a, b = max(0, -ul[1]), min(br[1], self.output_res) - ul[1]
39
+
40
+ cc, dd = max(0, ul[0]), min(br[0], self.output_res)
41
+ aa, bb = max(0, ul[1]), min(br[1], self.output_res)
42
+ hms[idx, aa:bb, cc:dd] = np.maximum(
43
+ hms[idx, aa:bb, cc:dd], self.g[a:b, c:d])
44
+ return hms
45
+
46
+ class MultiClassesHeatmapGenerator:
47
+ def __init__(self, num_classes, output_res=None,sigma=1):
48
+ '''
49
+ 损失为一次方时:
50
+ gt与pred相差sigma/2 loss为最大loss的20%, 相差sigma*0.75为29%, 相差sigma为38%, 相差sigma*2为68%,相差sigma*3为86%
51
+ 损失为平方时:
52
+ gt与pred相差sigma/2 loss为最大loss的6%, 相差sigma*0.75为13%, 相差sigma为22%, 相差sigma*2为63%,相差sigma*3为90%
53
+ 损失为三次方时:
54
+ gt与pred相差sigma/2 loss为最大loss的1.8%, 相差sigma*0.75为5.7%, 相差sigma为12.5%, 相差sigma*2为57%,相差sigma*3为90%
55
+ 损失为四次方时:
56
+ gt与pred相差sigma/2 loss为最大loss的0.5%, 相差sigma*0.75为2.5%, 相差sigma为7%, 相差sigma*2为51%,相差sigma*3为90%
57
+ output_res: [H,W]
58
+ '''
59
+ self.set_output_res(output_res)
60
+ self.num_classes = num_classes
61
+ if sigma < 0 and self.output_res is not None:
62
+ sigma = self.output_res/64
63
+ self.sigma = sigma
64
+ size = 6*sigma + 3
65
+ x = np.arange(0, size, 1, float)
66
+ y = x[:, np.newaxis]
67
+ x0, y0 = 3*sigma + 1, 3*sigma + 1
68
+ self.g = np.exp(- ((x - x0) ** 2 + (y - y0) ** 2) / (2 * sigma ** 2))
69
+
70
+ def set_output_res(self,output_res):
71
+ if output_res is None:
72
+ self.output_res = None
73
+ return
74
+ if not isinstance(output_res,Iterable):
75
+ output_res = (output_res,output_res)
76
+ self.output_res = output_res
77
+
78
+ def __call__(self, joints,labels,output_res=None):
79
+ '''
80
+ joints: [points_nr,N,2] (x,y) or WMCKeypoints
81
+ labels: [points_nr]
82
+ return:
83
+ [num_classes,H,W]
84
+ '''
85
+ if output_res is not None:
86
+ self.set_output_res(output_res)
87
+ hms = np.zeros((self.num_classes, self.output_res[0], self.output_res[1]),
88
+ dtype=np.float32)
89
+ sigma = self.sigma
90
+ for idx,pts in zip(labels,joints):
91
+ if isinstance(pts,WMCKeypointsItem):
92
+ pts = pts.points
93
+ for pt in pts:
94
+ x, y = int(pt[0]), int(pt[1])
95
+ if x < 0 or y < 0 or \
96
+ x >= self.output_res[1] or y >= self.output_res[0]:
97
+ continue
98
+
99
+ ul = int(np.round(x - 3 * sigma - 1)), int(np.round(y - 3 * sigma - 1))
100
+ br = int(np.round(x + 3 * sigma + 2)), int(np.round(y + 3 * sigma + 2))
101
+
102
+ c, d = max(0, -ul[0]), min(br[0], self.output_res[1]) - ul[0]
103
+ a, b = max(0, -ul[1]), min(br[1], self.output_res[0]) - ul[1]
104
+
105
+ cc, dd = max(0, ul[0]), min(br[0], self.output_res[1])
106
+ aa, bb = max(0, ul[1]), min(br[1], self.output_res[0])
107
+ hms[idx, aa:bb, cc:dd] = np.maximum(
108
+ hms[idx, aa:bb, cc:dd], self.g[a:b, c:d])
109
+ return hms
110
+
111
+
112
+
113
+ class ScaleAwareHeatmapGenerator():
114
+ def __init__(self, output_res, num_joints):
115
+ self.output_res = output_res
116
+ self.num_joints = num_joints
117
+
118
+ def get_gaussian_kernel(self, sigma):
119
+ size = 6*sigma + 3
120
+ x = np.arange(0, size, 1, float)
121
+ y = x[:, np.newaxis]
122
+ x0, y0 = 3*sigma + 1, 3*sigma + 1
123
+ g = np.exp(- ((x - x0) ** 2 + (y - y0) ** 2) / (2 * sigma ** 2))
124
+ return g
125
+
126
+ def __call__(self, joints):
127
+ hms = np.zeros((self.num_joints, self.output_res, self.output_res),
128
+ dtype=np.float32)
129
+ for p in joints:
130
+ sigma = p[0, 3]
131
+ g = self.get_gaussian_kernel(sigma)
132
+ for idx, pt in enumerate(p):
133
+ if pt[2] > 0:
134
+ x, y = int(pt[0]), int(pt[1])
135
+ if x < 0 or y < 0 or \
136
+ x >= self.output_res or y >= self.output_res:
137
+ continue
138
+
139
+ ul = int(np.round(x - 3 * sigma - 1)), int(np.round(y - 3 * sigma - 1))
140
+ br = int(np.round(x + 3 * sigma + 2)), int(np.round(y + 3 * sigma + 2))
141
+
142
+ c, d = max(0, -ul[0]), min(br[0], self.output_res) - ul[0]
143
+ a, b = max(0, -ul[1]), min(br[1], self.output_res) - ul[1]
144
+
145
+ cc, dd = max(0, ul[0]), min(br[0], self.output_res)
146
+ aa, bb = max(0, ul[1]), min(br[1], self.output_res)
147
+ hms[idx, aa:bb, cc:dd] = np.maximum(
148
+ hms[idx, aa:bb, cc:dd], g[a:b, c:d])
149
+ return hms