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,49 @@
|
|
|
1
|
+
#!/opt/anaconda3/bin/python
|
|
2
|
+
import argparse
|
|
3
|
+
import json
|
|
4
|
+
import os
|
|
5
|
+
import sys
|
|
6
|
+
import os.path as osp
|
|
7
|
+
|
|
8
|
+
import PIL.Image
|
|
9
|
+
import yaml
|
|
10
|
+
|
|
11
|
+
from labelme import utils
|
|
12
|
+
|
|
13
|
+
parser = argparse.ArgumentParser()
|
|
14
|
+
parser.add_argument('-json_file',type=str,default="",help="json file path")
|
|
15
|
+
flags,unparsed = parser.parse_known_args(sys.argv[1:])
|
|
16
|
+
|
|
17
|
+
def main():
|
|
18
|
+
|
|
19
|
+
json_file = flags.json_file
|
|
20
|
+
|
|
21
|
+
out_dir = osp.basename(json_file).replace('.', '_')
|
|
22
|
+
out_dir = osp.join(osp.dirname(json_file), out_dir)
|
|
23
|
+
os.mkdir(out_dir)
|
|
24
|
+
|
|
25
|
+
data = json.load(open(json_file))
|
|
26
|
+
|
|
27
|
+
img = utils.img_b64_to_arr(data['imageData'])
|
|
28
|
+
cls = utils.shapes_to_label(img.shape, data['shapes'],{"1":255,"2":128,"3":128})
|
|
29
|
+
|
|
30
|
+
PIL.Image.fromarray(cls).save(osp.join(out_dir, 'img.png'))
|
|
31
|
+
'''
|
|
32
|
+
lbl, lbl_names = utils.shapes_to_label(img.shape, data['shapes'],{"1":1,"2":2,"3":3})
|
|
33
|
+
|
|
34
|
+
lbl_viz = utils.draw_label(lbl, img, lbl_names)
|
|
35
|
+
|
|
36
|
+
PIL.Image.fromarray(img).save(osp.join(out_dir, 'img.png'))
|
|
37
|
+
PIL.Image.fromarray(lbl).save(osp.join(out_dir, 'label.png'))
|
|
38
|
+
PIL.Image.fromarray(lbl_viz).save(osp.join(out_dir, 'label_viz.png'))
|
|
39
|
+
|
|
40
|
+
info = dict(label_names=lbl_names)
|
|
41
|
+
|
|
42
|
+
with open(osp.join(out_dir, 'info.yaml'), 'w') as f:
|
|
43
|
+
yaml.safe_dump(info, f, default_flow_style=False)
|
|
44
|
+
|
|
45
|
+
print('wrote data to %s' % out_dir)
|
|
46
|
+
'''
|
|
47
|
+
|
|
48
|
+
if __name__ == '__main__':
|
|
49
|
+
main()
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import wml.wml_utils as wmlu
|
|
2
|
+
import os
|
|
3
|
+
import json
|
|
4
|
+
import numpy as np
|
|
5
|
+
import cv2 as cv
|
|
6
|
+
import copy
|
|
7
|
+
import wml.img_utils as wmli
|
|
8
|
+
import random
|
|
9
|
+
import matplotlib.pyplot as plt
|
|
10
|
+
import sys
|
|
11
|
+
import cv2
|
|
12
|
+
from wml.object_detection2.standard_names import *
|
|
13
|
+
import wml.object_detection2.bboxes as odb
|
|
14
|
+
from functools import partial
|
|
15
|
+
from .common import *
|
|
16
|
+
from .labelme_toolkit_fwd import *
|
|
17
|
+
import glob
|
|
18
|
+
from .labelme_base import LabelMeBase
|
|
19
|
+
|
|
20
|
+
class LabelMeData(LabelMeBase):
|
|
21
|
+
def __init__(self,label_text2id=None,shuffle=True,absolute_coord=True,
|
|
22
|
+
filter_empty_files=False,
|
|
23
|
+
resample_parameters=None,
|
|
24
|
+
use_polygon_mask=False,
|
|
25
|
+
read_data_kwargs={'circle_points_nr':20},**kwargs):
|
|
26
|
+
'''
|
|
27
|
+
label_text2id: func(name)->int
|
|
28
|
+
'''
|
|
29
|
+
super().__init__(label_text2id=label_text2id,
|
|
30
|
+
shuffle=shuffle,
|
|
31
|
+
absolute_coord=absolute_coord,
|
|
32
|
+
filter_empty_files=filter_empty_files,
|
|
33
|
+
resample_parameters=resample_parameters,
|
|
34
|
+
read_data_kwargs=read_data_kwargs,**kwargs)
|
|
35
|
+
self.use_polygon_mask = use_polygon_mask
|
|
36
|
+
|
|
37
|
+
def __getitem__(self,idx):
|
|
38
|
+
'''
|
|
39
|
+
:return:
|
|
40
|
+
full_path,img_size,category_ids,category_names,boxes,binary_masks,area,is_crowd,num_annotations_skipped
|
|
41
|
+
binary_masks:[N,H,W],全图
|
|
42
|
+
bboxes:[N,4] (ymin,xmin,ymax,xmax)
|
|
43
|
+
'''
|
|
44
|
+
img_file, json_file = self.files[idx]
|
|
45
|
+
image, annotations_list = read_labelme_data(json_file, None,mask_on=self.mask_on,use_semantic=True,
|
|
46
|
+
use_polygon_mask=self.use_polygon_mask,
|
|
47
|
+
**self.read_data_kwargs)
|
|
48
|
+
labels_names,bboxes = get_labels_and_bboxes(image,annotations_list,is_relative_coordinate=not self.absolute_coord)
|
|
49
|
+
difficult = np.array([v['difficult'] for v in annotations_list],dtype=np.bool)
|
|
50
|
+
masks = [ann["segmentation"] for ann in annotations_list] if self.mask_on else None
|
|
51
|
+
img_height = image['height']
|
|
52
|
+
img_width = image['width']
|
|
53
|
+
|
|
54
|
+
if not self.mask_on:
|
|
55
|
+
pass
|
|
56
|
+
elif self.use_polygon_mask:
|
|
57
|
+
masks = WPolygonMasks(masks,width=img_width,height=img_height)
|
|
58
|
+
elif len(masks)>0:
|
|
59
|
+
try:
|
|
60
|
+
masks = np.stack(masks,axis=0)
|
|
61
|
+
except:
|
|
62
|
+
masks = np.zeros(shape=[0,img_height,img_width],dtype=np.uint8)
|
|
63
|
+
else:
|
|
64
|
+
masks = np.zeros(shape=[len(labels_names),img_height,img_width],dtype=np.uint8)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
if self.label_text2id is not None:
|
|
68
|
+
labels = [self.label_text2id(x) for x in labels_names]
|
|
69
|
+
keep = [x is not None for x in labels]
|
|
70
|
+
labels = [x if x is not None else -1 for x in labels]
|
|
71
|
+
labels = np.array(labels,dtype=np.int32)
|
|
72
|
+
labels = labels[keep]
|
|
73
|
+
bboxes = bboxes[keep]
|
|
74
|
+
if masks is not None:
|
|
75
|
+
masks = masks[keep]
|
|
76
|
+
difficult = difficult[keep]
|
|
77
|
+
labels_names = np.array(labels_names)[keep]
|
|
78
|
+
else:
|
|
79
|
+
labels = None
|
|
80
|
+
|
|
81
|
+
return DetData(img_file, [image['height'],image['width']],labels, labels_names, bboxes, masks, None, difficult,None)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
if __name__ == "__main__":
|
|
85
|
+
#data_statistics("/home/vghost/ai/mldata/qualitycontrol/rdatasv3")
|
|
86
|
+
import wml.img_utils as wmli
|
|
87
|
+
import wml.object_detection2.visualization as odv
|
|
88
|
+
import matplotlib.pyplot as plt
|
|
89
|
+
ID_TO_TEXT = {1:{"id":1,"name":"a"},2:{"id":2,"name":"b"},3:{"id":3,"name":"c"}}
|
|
90
|
+
NAME_TO_ID = {}
|
|
91
|
+
for k,v in ID_TO_TEXT.items():
|
|
92
|
+
NAME_TO_ID[v["name"]] = v["id"]
|
|
93
|
+
def name_to_id(name):
|
|
94
|
+
return NAME_TO_ID[name]
|
|
95
|
+
|
|
96
|
+
data = LabelMeData(label_text2id=name_to_id,shuffle=True)
|
|
97
|
+
#data.read_data("/data/mldata/qualitycontrol/rdatasv5_splited/rdatasv5")
|
|
98
|
+
#data.read_data("/home/vghost/ai/mldata2/qualitycontrol/rdatav10_preproc")
|
|
99
|
+
#data.read_data("/home/vghost/ai/mldata2/qualitycontrol/rdatasv10_neg_preproc")
|
|
100
|
+
data.read_data("/home/vghost/ai/mldata2/qualitycontrol/rdatasv10_1x_neg_preproc")
|
|
101
|
+
#data.read_data("/home/vghost/ai/mldata2/qualitycontrol/x")
|
|
102
|
+
for x in data.get_items():
|
|
103
|
+
full_path, img_info,category_ids, category_names, boxes, binary_mask, area, is_crowd, num_annotations_skipped = x
|
|
104
|
+
img = wmli.imread(full_path)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def text_fn(classes, scores):
|
|
108
|
+
return ID_TO_TEXT[classes]['name']
|
|
109
|
+
|
|
110
|
+
odv.draw_bboxes_and_maskv2(
|
|
111
|
+
img=img, classes=category_ids, scores=None, bboxes=boxes, masks=binary_mask, color_fn=None,
|
|
112
|
+
text_fn=text_fn, thickness=4,
|
|
113
|
+
show_text=True,
|
|
114
|
+
fontScale=0.8)
|
|
115
|
+
plt.figure()
|
|
116
|
+
plt.imshow(img)
|
|
117
|
+
plt.show()
|