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.
- python_wml-3.0.0.dist-info/LICENSE +23 -0
- python_wml-3.0.0.dist-info/METADATA +51 -0
- python_wml-3.0.0.dist-info/RECORD +164 -0
- python_wml-3.0.0.dist-info/WHEEL +5 -0
- python_wml-3.0.0.dist-info/top_level.txt +1 -0
- wml/__init__.py +0 -0
- wml/basic_data_def/__init__.py +2 -0
- wml/basic_data_def/detection_data_def.py +279 -0
- wml/basic_data_def/io_data_def.py +2 -0
- wml/basic_img_utils.py +816 -0
- wml/img_patch.py +92 -0
- wml/img_utils.py +571 -0
- wml/iotoolkit/__init__.py +17 -0
- wml/iotoolkit/aic_keypoint.py +115 -0
- wml/iotoolkit/baidu_mask_toolkit.py +244 -0
- wml/iotoolkit/base_dataset.py +210 -0
- wml/iotoolkit/bboxes_statistics.py +515 -0
- wml/iotoolkit/build.py +0 -0
- wml/iotoolkit/cityscapes_toolkit.py +183 -0
- wml/iotoolkit/classification_data_statistics.py +25 -0
- wml/iotoolkit/coco_data_fwd.py +225 -0
- wml/iotoolkit/coco_keypoints.py +118 -0
- wml/iotoolkit/coco_keypoints_fmt2.py +103 -0
- wml/iotoolkit/coco_toolkit.py +397 -0
- wml/iotoolkit/coco_wholebody.py +269 -0
- wml/iotoolkit/common.py +108 -0
- wml/iotoolkit/crowd_pose.py +146 -0
- wml/iotoolkit/fast_labelme.py +110 -0
- wml/iotoolkit/image_folder.py +95 -0
- wml/iotoolkit/imgs_cache.py +58 -0
- wml/iotoolkit/imgs_reader_mt.py +73 -0
- wml/iotoolkit/labelme_base.py +102 -0
- wml/iotoolkit/labelme_json_to_img.py +49 -0
- wml/iotoolkit/labelme_toolkit.py +117 -0
- wml/iotoolkit/labelme_toolkit_fwd.py +733 -0
- wml/iotoolkit/labelmemckeypoints_dataset.py +169 -0
- wml/iotoolkit/lspet.py +48 -0
- wml/iotoolkit/mapillary_vistas_toolkit.py +269 -0
- wml/iotoolkit/mat_data.py +90 -0
- wml/iotoolkit/mckeypoints_statistics.py +28 -0
- wml/iotoolkit/mot_datasets.py +62 -0
- wml/iotoolkit/mpii.py +108 -0
- wml/iotoolkit/npmckeypoints_dataset.py +164 -0
- wml/iotoolkit/o365_to_coco.py +136 -0
- wml/iotoolkit/object365_toolkit.py +156 -0
- wml/iotoolkit/object365v2_toolkit.py +71 -0
- wml/iotoolkit/pascal_voc_data.py +51 -0
- wml/iotoolkit/pascal_voc_toolkit.py +194 -0
- wml/iotoolkit/pascal_voc_toolkit_fwd.py +473 -0
- wml/iotoolkit/penn_action.py +57 -0
- wml/iotoolkit/rawframe_dataset.py +129 -0
- wml/iotoolkit/rewrite_pascal_voc.py +28 -0
- wml/iotoolkit/semantic_data.py +49 -0
- wml/iotoolkit/split_file_by_type.py +29 -0
- wml/iotoolkit/sports_mot_datasets.py +78 -0
- wml/iotoolkit/vis_objectdetection_dataset.py +70 -0
- wml/iotoolkit/vis_torch_data.py +39 -0
- wml/iotoolkit/yolo_toolkit.py +38 -0
- wml/object_detection2/__init__.py +4 -0
- wml/object_detection2/basic_visualization.py +37 -0
- wml/object_detection2/bboxes.py +812 -0
- wml/object_detection2/data_process_toolkit.py +146 -0
- wml/object_detection2/keypoints.py +292 -0
- wml/object_detection2/mask.py +120 -0
- wml/object_detection2/metrics/__init__.py +3 -0
- wml/object_detection2/metrics/build.py +15 -0
- wml/object_detection2/metrics/classifier_toolkit.py +440 -0
- wml/object_detection2/metrics/common.py +71 -0
- wml/object_detection2/metrics/mckps_toolkit.py +338 -0
- wml/object_detection2/metrics/toolkit.py +1953 -0
- wml/object_detection2/npod_toolkit.py +361 -0
- wml/object_detection2/odtools.py +243 -0
- wml/object_detection2/standard_names.py +75 -0
- wml/object_detection2/visualization.py +956 -0
- wml/object_detection2/wmath.py +34 -0
- wml/semantic/__init__.py +0 -0
- wml/semantic/basic_toolkit.py +65 -0
- wml/semantic/mask_utils.py +156 -0
- wml/semantic/semantic_test.py +21 -0
- wml/semantic/structures.py +1 -0
- wml/semantic/toolkit.py +105 -0
- wml/semantic/visualization_utils.py +658 -0
- wml/threadtoolkit.py +50 -0
- wml/walgorithm.py +228 -0
- wml/wcollections.py +212 -0
- wml/wfilesystem.py +487 -0
- wml/wml_utils.py +657 -0
- wml/wstructures/__init__.py +4 -0
- wml/wstructures/common.py +9 -0
- wml/wstructures/keypoints_train_toolkit.py +149 -0
- wml/wstructures/kps_structures.py +579 -0
- wml/wstructures/mask_structures.py +1161 -0
- wml/wtorch/__init__.py +8 -0
- wml/wtorch/bboxes.py +104 -0
- wml/wtorch/classes_suppression.py +24 -0
- wml/wtorch/conv_module.py +181 -0
- wml/wtorch/conv_ws.py +144 -0
- wml/wtorch/data/__init__.py +16 -0
- wml/wtorch/data/_utils/__init__.py +45 -0
- wml/wtorch/data/_utils/collate.py +183 -0
- wml/wtorch/data/_utils/fetch.py +47 -0
- wml/wtorch/data/_utils/pin_memory.py +121 -0
- wml/wtorch/data/_utils/signal_handling.py +72 -0
- wml/wtorch/data/_utils/worker.py +227 -0
- wml/wtorch/data/base_data_loader_iter.py +93 -0
- wml/wtorch/data/dataloader.py +501 -0
- wml/wtorch/data/datapipes/__init__.py +1 -0
- wml/wtorch/data/datapipes/iter/__init__.py +12 -0
- wml/wtorch/data/datapipes/iter/batch.py +126 -0
- wml/wtorch/data/datapipes/iter/callable.py +92 -0
- wml/wtorch/data/datapipes/iter/listdirfiles.py +37 -0
- wml/wtorch/data/datapipes/iter/loadfilesfromdisk.py +30 -0
- wml/wtorch/data/datapipes/iter/readfilesfromtar.py +60 -0
- wml/wtorch/data/datapipes/iter/readfilesfromzip.py +63 -0
- wml/wtorch/data/datapipes/iter/sampler.py +94 -0
- wml/wtorch/data/datapipes/utils/__init__.py +0 -0
- wml/wtorch/data/datapipes/utils/common.py +65 -0
- wml/wtorch/data/dataset.py +354 -0
- wml/wtorch/data/datasets/__init__.py +4 -0
- wml/wtorch/data/datasets/common.py +53 -0
- wml/wtorch/data/datasets/listdirfilesdataset.py +36 -0
- wml/wtorch/data/datasets/loadfilesfromdiskdataset.py +30 -0
- wml/wtorch/data/distributed.py +135 -0
- wml/wtorch/data/multi_processing_data_loader_iter.py +866 -0
- wml/wtorch/data/sampler.py +267 -0
- wml/wtorch/data/single_process_data_loader_iter.py +24 -0
- wml/wtorch/data/test_data_loader.py +26 -0
- wml/wtorch/dataset_toolkit.py +67 -0
- wml/wtorch/depthwise_separable_conv_module.py +98 -0
- wml/wtorch/dist.py +591 -0
- wml/wtorch/dropblock/__init__.py +6 -0
- wml/wtorch/dropblock/dropblock.py +228 -0
- wml/wtorch/dropblock/dropout.py +40 -0
- wml/wtorch/dropblock/scheduler.py +48 -0
- wml/wtorch/ema.py +61 -0
- wml/wtorch/fc_module.py +73 -0
- wml/wtorch/functional.py +34 -0
- wml/wtorch/iter_dataset.py +26 -0
- wml/wtorch/loss.py +69 -0
- wml/wtorch/nets/__init__.py +0 -0
- wml/wtorch/nets/ckpt_toolkit.py +219 -0
- wml/wtorch/nets/fpn.py +276 -0
- wml/wtorch/nets/hrnet/__init__.py +0 -0
- wml/wtorch/nets/hrnet/config.py +2 -0
- wml/wtorch/nets/hrnet/hrnet.py +494 -0
- wml/wtorch/nets/misc.py +249 -0
- wml/wtorch/nets/resnet/__init__.py +0 -0
- wml/wtorch/nets/resnet/layers/__init__.py +17 -0
- wml/wtorch/nets/resnet/layers/aspp.py +144 -0
- wml/wtorch/nets/resnet/layers/batch_norm.py +231 -0
- wml/wtorch/nets/resnet/layers/blocks.py +111 -0
- wml/wtorch/nets/resnet/layers/wrappers.py +110 -0
- wml/wtorch/nets/resnet/r50_config.py +38 -0
- wml/wtorch/nets/resnet/resnet.py +691 -0
- wml/wtorch/nets/shape_spec.py +20 -0
- wml/wtorch/nets/simple_fpn.py +101 -0
- wml/wtorch/nms.py +109 -0
- wml/wtorch/nn.py +896 -0
- wml/wtorch/ocr_block.py +193 -0
- wml/wtorch/summary.py +331 -0
- wml/wtorch/train_toolkit.py +603 -0
- wml/wtorch/transformer_blocks.py +266 -0
- wml/wtorch/utils.py +719 -0
- 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
|