paddlex 2.1.0__py3-none-any.whl → 3.0.0rc0__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 (1708) hide show
  1. paddlex/.version +1 -0
  2. paddlex/__init__.py +52 -19
  3. paddlex/__main__.py +39 -0
  4. paddlex/configs/modules/3d_bev_detection/BEVFusion.yaml +38 -0
  5. paddlex/configs/modules/doc_text_orientation/PP-LCNet_x1_0_doc_ori.yaml +41 -0
  6. paddlex/configs/modules/face_detection/BlazeFace-FPN-SSH.yaml +40 -0
  7. paddlex/configs/modules/face_detection/BlazeFace.yaml +40 -0
  8. paddlex/configs/modules/face_detection/PP-YOLOE_plus-S_face.yaml +40 -0
  9. paddlex/configs/modules/face_detection/PicoDet_LCNet_x2_5_face.yaml +40 -0
  10. paddlex/configs/modules/face_feature/MobileFaceNet.yaml +41 -0
  11. paddlex/configs/modules/face_feature/ResNet50_face.yaml +41 -0
  12. paddlex/configs/modules/formula_recognition/LaTeX_OCR_rec.yaml +40 -0
  13. paddlex/configs/modules/formula_recognition/PP-FormulaNet-L.yaml +40 -0
  14. paddlex/configs/modules/formula_recognition/PP-FormulaNet-S.yaml +40 -0
  15. paddlex/configs/modules/formula_recognition/UniMERNet.yaml +40 -0
  16. paddlex/configs/modules/human_detection/PP-YOLOE-L_human.yaml +42 -0
  17. paddlex/configs/modules/human_detection/PP-YOLOE-S_human.yaml +42 -0
  18. paddlex/configs/modules/image_anomaly_detection/STFPM.yaml +41 -0
  19. paddlex/configs/modules/image_classification/CLIP_vit_base_patch16_224.yaml +41 -0
  20. paddlex/configs/modules/image_classification/CLIP_vit_large_patch14_224.yaml +41 -0
  21. paddlex/configs/modules/image_classification/ConvNeXt_base_224.yaml +41 -0
  22. paddlex/configs/modules/image_classification/ConvNeXt_base_384.yaml +41 -0
  23. paddlex/configs/modules/image_classification/ConvNeXt_large_224.yaml +41 -0
  24. paddlex/configs/modules/image_classification/ConvNeXt_large_384.yaml +41 -0
  25. paddlex/configs/modules/image_classification/ConvNeXt_small.yaml +41 -0
  26. paddlex/configs/modules/image_classification/ConvNeXt_tiny.yaml +41 -0
  27. paddlex/configs/modules/image_classification/FasterNet-L.yaml +40 -0
  28. paddlex/configs/modules/image_classification/FasterNet-M.yaml +40 -0
  29. paddlex/configs/modules/image_classification/FasterNet-S.yaml +40 -0
  30. paddlex/configs/modules/image_classification/FasterNet-T0.yaml +40 -0
  31. paddlex/configs/modules/image_classification/FasterNet-T1.yaml +40 -0
  32. paddlex/configs/modules/image_classification/FasterNet-T2.yaml +40 -0
  33. paddlex/configs/modules/image_classification/MobileNetV1_x0_25.yaml +41 -0
  34. paddlex/configs/modules/image_classification/MobileNetV1_x0_5.yaml +41 -0
  35. paddlex/configs/modules/image_classification/MobileNetV1_x0_75.yaml +41 -0
  36. paddlex/configs/modules/image_classification/MobileNetV1_x1_0.yaml +41 -0
  37. paddlex/configs/modules/image_classification/MobileNetV2_x0_25.yaml +41 -0
  38. paddlex/configs/modules/image_classification/MobileNetV2_x0_5.yaml +41 -0
  39. paddlex/configs/modules/image_classification/MobileNetV2_x1_0.yaml +41 -0
  40. paddlex/configs/modules/image_classification/MobileNetV2_x1_5.yaml +41 -0
  41. paddlex/configs/modules/image_classification/MobileNetV2_x2_0.yaml +41 -0
  42. paddlex/configs/modules/image_classification/MobileNetV3_large_x0_35.yaml +41 -0
  43. paddlex/configs/modules/image_classification/MobileNetV3_large_x0_5.yaml +41 -0
  44. paddlex/configs/modules/image_classification/MobileNetV3_large_x0_75.yaml +41 -0
  45. paddlex/configs/modules/image_classification/MobileNetV3_large_x1_0.yaml +41 -0
  46. paddlex/configs/modules/image_classification/MobileNetV3_large_x1_25.yaml +41 -0
  47. paddlex/configs/modules/image_classification/MobileNetV3_small_x0_35.yaml +41 -0
  48. paddlex/configs/modules/image_classification/MobileNetV3_small_x0_5.yaml +41 -0
  49. paddlex/configs/modules/image_classification/MobileNetV3_small_x0_75.yaml +41 -0
  50. paddlex/configs/modules/image_classification/MobileNetV3_small_x1_0.yaml +41 -0
  51. paddlex/configs/modules/image_classification/MobileNetV3_small_x1_25.yaml +41 -0
  52. paddlex/configs/modules/image_classification/MobileNetV4_conv_large.yaml +41 -0
  53. paddlex/configs/modules/image_classification/MobileNetV4_conv_medium.yaml +41 -0
  54. paddlex/configs/modules/image_classification/MobileNetV4_conv_small.yaml +41 -0
  55. paddlex/configs/modules/image_classification/MobileNetV4_hybrid_large.yaml +41 -0
  56. paddlex/configs/modules/image_classification/MobileNetV4_hybrid_medium.yaml +41 -0
  57. paddlex/configs/modules/image_classification/PP-HGNetV2-B0.yaml +41 -0
  58. paddlex/configs/modules/image_classification/PP-HGNetV2-B1.yaml +41 -0
  59. paddlex/configs/modules/image_classification/PP-HGNetV2-B2.yaml +41 -0
  60. paddlex/configs/modules/image_classification/PP-HGNetV2-B3.yaml +41 -0
  61. paddlex/configs/modules/image_classification/PP-HGNetV2-B4.yaml +41 -0
  62. paddlex/configs/modules/image_classification/PP-HGNetV2-B5.yaml +41 -0
  63. paddlex/configs/modules/image_classification/PP-HGNetV2-B6.yaml +41 -0
  64. paddlex/configs/modules/image_classification/PP-HGNet_base.yaml +41 -0
  65. paddlex/configs/modules/image_classification/PP-HGNet_small.yaml +41 -0
  66. paddlex/configs/modules/image_classification/PP-HGNet_tiny.yaml +41 -0
  67. paddlex/configs/modules/image_classification/PP-LCNetV2_base.yaml +41 -0
  68. paddlex/configs/modules/image_classification/PP-LCNetV2_large.yaml +41 -0
  69. paddlex/configs/modules/image_classification/PP-LCNetV2_small.yaml +41 -0
  70. paddlex/configs/modules/image_classification/PP-LCNet_x0_25.yaml +41 -0
  71. paddlex/configs/modules/image_classification/PP-LCNet_x0_35.yaml +41 -0
  72. paddlex/configs/modules/image_classification/PP-LCNet_x0_5.yaml +41 -0
  73. paddlex/configs/modules/image_classification/PP-LCNet_x0_75.yaml +41 -0
  74. paddlex/configs/modules/image_classification/PP-LCNet_x1_0.yaml +41 -0
  75. paddlex/configs/modules/image_classification/PP-LCNet_x1_5.yaml +41 -0
  76. paddlex/configs/modules/image_classification/PP-LCNet_x2_0.yaml +41 -0
  77. paddlex/configs/modules/image_classification/PP-LCNet_x2_5.yaml +41 -0
  78. paddlex/configs/modules/image_classification/ResNet101.yaml +41 -0
  79. paddlex/configs/modules/image_classification/ResNet101_vd.yaml +41 -0
  80. paddlex/configs/modules/image_classification/ResNet152.yaml +41 -0
  81. paddlex/configs/modules/image_classification/ResNet152_vd.yaml +41 -0
  82. paddlex/configs/modules/image_classification/ResNet18.yaml +41 -0
  83. paddlex/configs/modules/image_classification/ResNet18_vd.yaml +41 -0
  84. paddlex/configs/modules/image_classification/ResNet200_vd.yaml +41 -0
  85. paddlex/configs/modules/image_classification/ResNet34.yaml +41 -0
  86. paddlex/configs/modules/image_classification/ResNet34_vd.yaml +41 -0
  87. paddlex/configs/modules/image_classification/ResNet50.yaml +41 -0
  88. paddlex/configs/modules/image_classification/ResNet50_vd.yaml +41 -0
  89. paddlex/configs/modules/image_classification/StarNet-S1.yaml +41 -0
  90. paddlex/configs/modules/image_classification/StarNet-S2.yaml +41 -0
  91. paddlex/configs/modules/image_classification/StarNet-S3.yaml +41 -0
  92. paddlex/configs/modules/image_classification/StarNet-S4.yaml +41 -0
  93. paddlex/configs/modules/image_classification/SwinTransformer_base_patch4_window12_384.yaml +41 -0
  94. paddlex/configs/modules/image_classification/SwinTransformer_base_patch4_window7_224.yaml +41 -0
  95. paddlex/configs/modules/image_classification/SwinTransformer_large_patch4_window12_384.yaml +41 -0
  96. paddlex/configs/modules/image_classification/SwinTransformer_large_patch4_window7_224.yaml +41 -0
  97. paddlex/configs/modules/image_classification/SwinTransformer_small_patch4_window7_224.yaml +41 -0
  98. paddlex/configs/modules/image_classification/SwinTransformer_tiny_patch4_window7_224.yaml +41 -0
  99. paddlex/configs/modules/image_feature/PP-ShiTuV2_rec.yaml +42 -0
  100. paddlex/configs/modules/image_feature/PP-ShiTuV2_rec_CLIP_vit_base.yaml +42 -0
  101. paddlex/configs/modules/image_feature/PP-ShiTuV2_rec_CLIP_vit_large.yaml +41 -0
  102. paddlex/configs/modules/image_multilabel_classification/CLIP_vit_base_patch16_448_ML.yaml +41 -0
  103. paddlex/configs/modules/image_multilabel_classification/PP-HGNetV2-B0_ML.yaml +41 -0
  104. paddlex/configs/modules/image_multilabel_classification/PP-HGNetV2-B4_ML.yaml +41 -0
  105. paddlex/configs/modules/image_multilabel_classification/PP-HGNetV2-B6_ML.yaml +41 -0
  106. paddlex/configs/modules/image_multilabel_classification/PP-LCNet_x1_0_ML.yaml +41 -0
  107. paddlex/configs/modules/image_multilabel_classification/ResNet50_ML.yaml +41 -0
  108. paddlex/configs/modules/image_unwarping/UVDoc.yaml +12 -0
  109. paddlex/configs/modules/instance_segmentation/Cascade-MaskRCNN-ResNet50-FPN.yaml +40 -0
  110. paddlex/configs/modules/instance_segmentation/Cascade-MaskRCNN-ResNet50-vd-SSLDv2-FPN.yaml +40 -0
  111. paddlex/configs/modules/instance_segmentation/Mask-RT-DETR-H.yaml +40 -0
  112. paddlex/configs/modules/instance_segmentation/Mask-RT-DETR-L.yaml +40 -0
  113. paddlex/configs/modules/instance_segmentation/Mask-RT-DETR-M.yaml +40 -0
  114. paddlex/configs/modules/instance_segmentation/Mask-RT-DETR-S.yaml +40 -0
  115. paddlex/configs/modules/instance_segmentation/Mask-RT-DETR-X.yaml +40 -0
  116. paddlex/configs/modules/instance_segmentation/MaskRCNN-ResNeXt101-vd-FPN.yaml +39 -0
  117. paddlex/configs/modules/instance_segmentation/MaskRCNN-ResNet101-FPN.yaml +40 -0
  118. paddlex/configs/modules/instance_segmentation/MaskRCNN-ResNet101-vd-FPN.yaml +40 -0
  119. paddlex/configs/modules/instance_segmentation/MaskRCNN-ResNet50-FPN.yaml +40 -0
  120. paddlex/configs/modules/instance_segmentation/MaskRCNN-ResNet50-vd-FPN.yaml +40 -0
  121. paddlex/configs/modules/instance_segmentation/MaskRCNN-ResNet50.yaml +40 -0
  122. paddlex/configs/modules/instance_segmentation/PP-YOLOE_seg-S.yaml +40 -0
  123. paddlex/configs/modules/instance_segmentation/SOLOv2.yaml +40 -0
  124. paddlex/configs/modules/keypoint_detection/PP-TinyPose_128x96.yaml +40 -0
  125. paddlex/configs/modules/keypoint_detection/PP-TinyPose_256x192.yaml +40 -0
  126. paddlex/configs/modules/layout_detection/PP-DocLayout-L.yaml +40 -0
  127. paddlex/configs/modules/layout_detection/PP-DocLayout-M.yaml +40 -0
  128. paddlex/configs/modules/layout_detection/PP-DocLayout-S.yaml +40 -0
  129. paddlex/configs/modules/layout_detection/PicoDet-L_layout_17cls.yaml +40 -0
  130. paddlex/configs/modules/layout_detection/PicoDet-L_layout_3cls.yaml +40 -0
  131. paddlex/configs/modules/layout_detection/PicoDet-S_layout_17cls.yaml +40 -0
  132. paddlex/configs/modules/layout_detection/PicoDet-S_layout_3cls.yaml +40 -0
  133. paddlex/configs/modules/layout_detection/PicoDet_layout_1x.yaml +40 -0
  134. paddlex/configs/modules/layout_detection/PicoDet_layout_1x_table.yaml +40 -0
  135. paddlex/configs/modules/layout_detection/RT-DETR-H_layout_17cls.yaml +40 -0
  136. paddlex/configs/modules/layout_detection/RT-DETR-H_layout_3cls.yaml +40 -0
  137. paddlex/configs/modules/mainbody_detection/PP-ShiTuV2_det.yaml +41 -0
  138. paddlex/configs/modules/multilingual_speech_recognition/whisper_base.yaml +12 -0
  139. paddlex/configs/modules/multilingual_speech_recognition/whisper_large.yaml +12 -0
  140. paddlex/configs/modules/multilingual_speech_recognition/whisper_medium.yaml +12 -0
  141. paddlex/configs/modules/multilingual_speech_recognition/whisper_small.yaml +12 -0
  142. paddlex/configs/modules/multilingual_speech_recognition/whisper_tiny.yaml +12 -0
  143. paddlex/configs/modules/object_detection/Cascade-FasterRCNN-ResNet50-FPN.yaml +41 -0
  144. paddlex/configs/modules/object_detection/Cascade-FasterRCNN-ResNet50-vd-SSLDv2-FPN.yaml +42 -0
  145. paddlex/configs/modules/object_detection/CenterNet-DLA-34.yaml +41 -0
  146. paddlex/configs/modules/object_detection/CenterNet-ResNet50.yaml +41 -0
  147. paddlex/configs/modules/object_detection/Co-DINO-R50.yaml +40 -0
  148. paddlex/configs/modules/object_detection/Co-DINO-Swin-L.yaml +40 -0
  149. paddlex/configs/modules/object_detection/Co-Deformable-DETR-R50.yaml +40 -0
  150. paddlex/configs/modules/object_detection/Co-Deformable-DETR-Swin-T.yaml +40 -0
  151. paddlex/configs/modules/object_detection/DETR-R50.yaml +42 -0
  152. paddlex/configs/modules/object_detection/FCOS-ResNet50.yaml +41 -0
  153. paddlex/configs/modules/object_detection/FasterRCNN-ResNeXt101-vd-FPN.yaml +42 -0
  154. paddlex/configs/modules/object_detection/FasterRCNN-ResNet101-FPN.yaml +42 -0
  155. paddlex/configs/modules/object_detection/FasterRCNN-ResNet101.yaml +42 -0
  156. paddlex/configs/modules/object_detection/FasterRCNN-ResNet34-FPN.yaml +42 -0
  157. paddlex/configs/modules/object_detection/FasterRCNN-ResNet50-FPN.yaml +42 -0
  158. paddlex/configs/modules/object_detection/FasterRCNN-ResNet50-vd-FPN.yaml +42 -0
  159. paddlex/configs/modules/object_detection/FasterRCNN-ResNet50-vd-SSLDv2-FPN.yaml +42 -0
  160. paddlex/configs/modules/object_detection/FasterRCNN-ResNet50.yaml +42 -0
  161. paddlex/configs/modules/object_detection/FasterRCNN-Swin-Tiny-FPN.yaml +42 -0
  162. paddlex/configs/modules/object_detection/PP-YOLOE_plus-L.yaml +40 -0
  163. paddlex/configs/modules/object_detection/PP-YOLOE_plus-M.yaml +40 -0
  164. paddlex/configs/modules/object_detection/PP-YOLOE_plus-S.yaml +40 -0
  165. paddlex/configs/modules/object_detection/PP-YOLOE_plus-X.yaml +40 -0
  166. paddlex/configs/modules/object_detection/PicoDet-L.yaml +40 -0
  167. paddlex/configs/modules/object_detection/PicoDet-M.yaml +42 -0
  168. paddlex/configs/modules/object_detection/PicoDet-S.yaml +40 -0
  169. paddlex/configs/modules/object_detection/PicoDet-XS.yaml +42 -0
  170. paddlex/configs/modules/object_detection/RT-DETR-H.yaml +40 -0
  171. paddlex/configs/modules/object_detection/RT-DETR-L.yaml +40 -0
  172. paddlex/configs/modules/object_detection/RT-DETR-R18.yaml +40 -0
  173. paddlex/configs/modules/object_detection/RT-DETR-R50.yaml +40 -0
  174. paddlex/configs/modules/object_detection/RT-DETR-X.yaml +40 -0
  175. paddlex/configs/modules/object_detection/YOLOX-L.yaml +40 -0
  176. paddlex/configs/modules/object_detection/YOLOX-M.yaml +40 -0
  177. paddlex/configs/modules/object_detection/YOLOX-N.yaml +40 -0
  178. paddlex/configs/modules/object_detection/YOLOX-S.yaml +40 -0
  179. paddlex/configs/modules/object_detection/YOLOX-T.yaml +40 -0
  180. paddlex/configs/modules/object_detection/YOLOX-X.yaml +40 -0
  181. paddlex/configs/modules/object_detection/YOLOv3-DarkNet53.yaml +40 -0
  182. paddlex/configs/modules/object_detection/YOLOv3-MobileNetV3.yaml +40 -0
  183. paddlex/configs/modules/object_detection/YOLOv3-ResNet50_vd_DCN.yaml +40 -0
  184. paddlex/configs/modules/open_vocabulary_detection/GroundingDINO-T.yaml +13 -0
  185. paddlex/configs/modules/open_vocabulary_segmentation/SAM-H_box.yaml +17 -0
  186. paddlex/configs/modules/open_vocabulary_segmentation/SAM-H_point.yaml +15 -0
  187. paddlex/configs/modules/pedestrian_attribute_recognition/PP-LCNet_x1_0_pedestrian_attribute.yaml +41 -0
  188. paddlex/configs/modules/rotated_object_detection/PP-YOLOE-R-L.yaml +40 -0
  189. paddlex/configs/modules/seal_text_detection/PP-OCRv4_mobile_seal_det.yaml +40 -0
  190. paddlex/configs/modules/seal_text_detection/PP-OCRv4_server_seal_det.yaml +40 -0
  191. paddlex/configs/modules/semantic_segmentation/Deeplabv3-R101.yaml +40 -0
  192. paddlex/configs/modules/semantic_segmentation/Deeplabv3-R50.yaml +40 -0
  193. paddlex/configs/modules/semantic_segmentation/Deeplabv3_Plus-R101.yaml +40 -0
  194. paddlex/configs/modules/semantic_segmentation/Deeplabv3_Plus-R50.yaml +40 -0
  195. paddlex/configs/modules/semantic_segmentation/MaskFormer_small.yaml +42 -0
  196. paddlex/configs/modules/semantic_segmentation/MaskFormer_tiny.yaml +42 -0
  197. paddlex/configs/modules/semantic_segmentation/OCRNet_HRNet-W18.yaml +40 -0
  198. paddlex/configs/modules/semantic_segmentation/OCRNet_HRNet-W48.yaml +40 -0
  199. paddlex/configs/modules/semantic_segmentation/PP-LiteSeg-B.yaml +41 -0
  200. paddlex/configs/modules/semantic_segmentation/PP-LiteSeg-T.yaml +40 -0
  201. paddlex/configs/modules/semantic_segmentation/SeaFormer_base.yaml +40 -0
  202. paddlex/configs/modules/semantic_segmentation/SeaFormer_large.yaml +40 -0
  203. paddlex/configs/modules/semantic_segmentation/SeaFormer_small.yaml +40 -0
  204. paddlex/configs/modules/semantic_segmentation/SeaFormer_tiny.yaml +40 -0
  205. paddlex/configs/modules/semantic_segmentation/SegFormer-B0.yaml +40 -0
  206. paddlex/configs/modules/semantic_segmentation/SegFormer-B1.yaml +40 -0
  207. paddlex/configs/modules/semantic_segmentation/SegFormer-B2.yaml +40 -0
  208. paddlex/configs/modules/semantic_segmentation/SegFormer-B3.yaml +40 -0
  209. paddlex/configs/modules/semantic_segmentation/SegFormer-B4.yaml +40 -0
  210. paddlex/configs/modules/semantic_segmentation/SegFormer-B5.yaml +40 -0
  211. paddlex/configs/modules/small_object_detection/PP-YOLOE_plus_SOD-L.yaml +42 -0
  212. paddlex/configs/modules/small_object_detection/PP-YOLOE_plus_SOD-S.yaml +42 -0
  213. paddlex/configs/modules/small_object_detection/PP-YOLOE_plus_SOD-largesize-L.yaml +42 -0
  214. paddlex/configs/modules/table_cells_detection/RT-DETR-L_wired_table_cell_det.yaml +40 -0
  215. paddlex/configs/modules/table_cells_detection/RT-DETR-L_wireless_table_cell_det.yaml +40 -0
  216. paddlex/configs/modules/table_classification/PP-LCNet_x1_0_table_cls.yaml +41 -0
  217. paddlex/configs/modules/table_structure_recognition/SLANeXt_wired.yaml +39 -0
  218. paddlex/configs/modules/table_structure_recognition/SLANeXt_wireless.yaml +39 -0
  219. paddlex/configs/modules/table_structure_recognition/SLANet.yaml +39 -0
  220. paddlex/configs/modules/table_structure_recognition/SLANet_plus.yaml +39 -0
  221. paddlex/configs/modules/text_detection/PP-OCRv3_mobile_det.yaml +40 -0
  222. paddlex/configs/modules/text_detection/PP-OCRv3_server_det.yaml +40 -0
  223. paddlex/configs/modules/text_detection/PP-OCRv4_mobile_det.yaml +40 -0
  224. paddlex/configs/modules/text_detection/PP-OCRv4_server_det.yaml +40 -0
  225. paddlex/configs/modules/text_recognition/PP-OCRv3_mobile_rec.yaml +39 -0
  226. paddlex/configs/modules/text_recognition/PP-OCRv4_mobile_rec.yaml +39 -0
  227. paddlex/configs/modules/text_recognition/PP-OCRv4_server_rec.yaml +39 -0
  228. paddlex/configs/modules/text_recognition/PP-OCRv4_server_rec_doc.yaml +39 -0
  229. paddlex/configs/modules/text_recognition/arabic_PP-OCRv3_mobile_rec.yaml +39 -0
  230. paddlex/configs/modules/text_recognition/ch_RepSVTR_rec.yaml +39 -0
  231. paddlex/configs/modules/text_recognition/ch_SVTRv2_rec.yaml +39 -0
  232. paddlex/configs/modules/text_recognition/chinese_cht_PP-OCRv3_mobile_rec.yaml +39 -0
  233. paddlex/configs/modules/text_recognition/cyrillic_PP-OCRv3_mobile_rec.yaml +39 -0
  234. paddlex/configs/modules/text_recognition/devanagari_PP-OCRv3_mobile_rec.yaml +39 -0
  235. paddlex/configs/modules/text_recognition/en_PP-OCRv3_mobile_rec.yaml +39 -0
  236. paddlex/configs/modules/text_recognition/en_PP-OCRv4_mobile_rec.yaml +39 -0
  237. paddlex/configs/modules/text_recognition/japan_PP-OCRv3_mobile_rec.yaml +39 -0
  238. paddlex/configs/modules/text_recognition/ka_PP-OCRv3_mobile_rec.yaml +39 -0
  239. paddlex/configs/modules/text_recognition/korean_PP-OCRv3_mobile_rec.yaml +39 -0
  240. paddlex/configs/modules/text_recognition/latin_PP-OCRv3_mobile_rec.yaml +39 -0
  241. paddlex/configs/modules/text_recognition/ta_PP-OCRv3_mobile_rec.yaml +39 -0
  242. paddlex/configs/modules/text_recognition/te_PP-OCRv3_mobile_rec.yaml +39 -0
  243. paddlex/configs/modules/textline_orientation/PP-LCNet_x0_25_textline_ori.yaml +41 -0
  244. paddlex/configs/modules/ts_anomaly_detection/AutoEncoder_ad.yaml +37 -0
  245. paddlex/configs/modules/ts_anomaly_detection/DLinear_ad.yaml +37 -0
  246. paddlex/configs/modules/ts_anomaly_detection/Nonstationary_ad.yaml +37 -0
  247. paddlex/configs/modules/ts_anomaly_detection/PatchTST_ad.yaml +37 -0
  248. paddlex/configs/modules/ts_anomaly_detection/TimesNet_ad.yaml +37 -0
  249. paddlex/configs/modules/ts_classification/TimesNet_cls.yaml +37 -0
  250. paddlex/configs/modules/ts_forecast/DLinear.yaml +38 -0
  251. paddlex/configs/modules/ts_forecast/NLinear.yaml +38 -0
  252. paddlex/configs/modules/ts_forecast/Nonstationary.yaml +38 -0
  253. paddlex/configs/modules/ts_forecast/PatchTST.yaml +38 -0
  254. paddlex/configs/modules/ts_forecast/RLinear.yaml +38 -0
  255. paddlex/configs/modules/ts_forecast/TiDE.yaml +38 -0
  256. paddlex/configs/modules/ts_forecast/TimesNet.yaml +38 -0
  257. paddlex/configs/modules/vehicle_attribute_recognition/PP-LCNet_x1_0_vehicle_attribute.yaml +41 -0
  258. paddlex/configs/modules/vehicle_detection/PP-YOLOE-L_vehicle.yaml +41 -0
  259. paddlex/configs/modules/vehicle_detection/PP-YOLOE-S_vehicle.yaml +42 -0
  260. paddlex/configs/modules/video_classification/PP-TSM-R50_8frames_uniform.yaml +42 -0
  261. paddlex/configs/modules/video_classification/PP-TSMv2-LCNetV2_16frames_uniform.yaml +42 -0
  262. paddlex/configs/modules/video_classification/PP-TSMv2-LCNetV2_8frames_uniform.yaml +42 -0
  263. paddlex/configs/modules/video_detection/YOWO.yaml +40 -0
  264. paddlex/configs/pipelines/3d_bev_detection.yaml +9 -0
  265. paddlex/configs/pipelines/OCR.yaml +44 -0
  266. paddlex/configs/pipelines/PP-ChatOCRv3-doc.yaml +149 -0
  267. paddlex/configs/pipelines/PP-ChatOCRv4-doc.yaml +184 -0
  268. paddlex/configs/pipelines/PP-ShiTuV2.yaml +18 -0
  269. paddlex/configs/pipelines/PP-StructureV3.yaml +226 -0
  270. paddlex/configs/pipelines/anomaly_detection.yaml +8 -0
  271. paddlex/configs/pipelines/doc_preprocessor.yaml +15 -0
  272. paddlex/configs/pipelines/face_recognition.yaml +18 -0
  273. paddlex/configs/pipelines/formula_recognition.yaml +39 -0
  274. paddlex/configs/pipelines/human_keypoint_detection.yaml +17 -0
  275. paddlex/configs/pipelines/image_classification.yaml +10 -0
  276. paddlex/configs/pipelines/image_multilabel_classification.yaml +9 -0
  277. paddlex/configs/pipelines/instance_segmentation.yaml +10 -0
  278. paddlex/configs/pipelines/layout_parsing.yaml +101 -0
  279. paddlex/configs/pipelines/multilingual_speech_recognition.yaml +9 -0
  280. paddlex/configs/pipelines/object_detection.yaml +10 -0
  281. paddlex/configs/pipelines/open_vocabulary_detection.yaml +12 -0
  282. paddlex/configs/pipelines/open_vocabulary_segmentation.yaml +13 -0
  283. paddlex/configs/pipelines/pedestrian_attribute_recognition.yaml +15 -0
  284. paddlex/configs/pipelines/rotated_object_detection.yaml +10 -0
  285. paddlex/configs/pipelines/seal_recognition.yaml +51 -0
  286. paddlex/configs/pipelines/semantic_segmentation.yaml +10 -0
  287. paddlex/configs/pipelines/small_object_detection.yaml +10 -0
  288. paddlex/configs/pipelines/table_recognition.yaml +56 -0
  289. paddlex/configs/pipelines/table_recognition_v2.yaml +76 -0
  290. paddlex/configs/pipelines/ts_anomaly_detection.yaml +8 -0
  291. paddlex/configs/pipelines/ts_classification.yaml +8 -0
  292. paddlex/configs/pipelines/ts_forecast.yaml +8 -0
  293. paddlex/configs/pipelines/vehicle_attribute_recognition.yaml +15 -0
  294. paddlex/configs/pipelines/video_classification.yaml +9 -0
  295. paddlex/configs/pipelines/video_detection.yaml +10 -0
  296. paddlex/engine.py +54 -0
  297. paddlex/hpip_links.html +19 -0
  298. paddlex/inference/__init__.py +19 -0
  299. paddlex/inference/common/__init__.py +13 -0
  300. paddlex/inference/common/batch_sampler/__init__.py +20 -0
  301. paddlex/inference/common/batch_sampler/audio_batch_sampler.py +84 -0
  302. paddlex/inference/common/batch_sampler/base_batch_sampler.py +90 -0
  303. paddlex/inference/common/batch_sampler/det_3d_batch_sampler.py +147 -0
  304. paddlex/inference/common/batch_sampler/image_batch_sampler.py +136 -0
  305. paddlex/inference/common/batch_sampler/ts_batch_sampler.py +110 -0
  306. paddlex/inference/common/batch_sampler/video_batch_sampler.py +94 -0
  307. paddlex/inference/common/reader/__init__.py +19 -0
  308. paddlex/inference/common/reader/audio_reader.py +46 -0
  309. paddlex/inference/common/reader/det_3d_reader.py +239 -0
  310. paddlex/inference/common/reader/image_reader.py +69 -0
  311. paddlex/inference/common/reader/ts_reader.py +45 -0
  312. paddlex/inference/common/reader/video_reader.py +42 -0
  313. paddlex/inference/common/result/__init__.py +29 -0
  314. paddlex/inference/common/result/base_cv_result.py +31 -0
  315. paddlex/inference/common/result/base_result.py +70 -0
  316. paddlex/inference/common/result/base_ts_result.py +42 -0
  317. paddlex/inference/common/result/base_video_result.py +36 -0
  318. paddlex/inference/common/result/mixin.py +703 -0
  319. paddlex/inference/models/3d_bev_detection/__init__.py +15 -0
  320. paddlex/inference/models/3d_bev_detection/predictor.py +314 -0
  321. paddlex/inference/models/3d_bev_detection/processors.py +978 -0
  322. paddlex/inference/models/3d_bev_detection/result.py +65 -0
  323. paddlex/inference/models/3d_bev_detection/visualizer_3d.py +131 -0
  324. paddlex/inference/models/__init__.py +130 -0
  325. paddlex/inference/models/anomaly_detection/__init__.py +15 -0
  326. paddlex/inference/models/anomaly_detection/predictor.py +145 -0
  327. paddlex/inference/models/anomaly_detection/processors.py +46 -0
  328. paddlex/inference/models/anomaly_detection/result.py +70 -0
  329. paddlex/inference/models/base/__init__.py +15 -0
  330. paddlex/inference/models/base/predictor/__init__.py +16 -0
  331. paddlex/inference/models/base/predictor/base_predictor.py +175 -0
  332. paddlex/inference/models/base/predictor/basic_predictor.py +139 -0
  333. paddlex/inference/models/common/__init__.py +35 -0
  334. paddlex/inference/models/common/static_infer.py +329 -0
  335. paddlex/inference/models/common/tokenizer/__init__.py +17 -0
  336. paddlex/inference/models/common/tokenizer/bert_tokenizer.py +655 -0
  337. paddlex/inference/models/common/tokenizer/gpt_tokenizer.py +451 -0
  338. paddlex/inference/models/common/tokenizer/tokenizer_utils.py +2141 -0
  339. paddlex/inference/models/common/tokenizer/tokenizer_utils_base.py +3504 -0
  340. paddlex/inference/models/common/tokenizer/utils.py +66 -0
  341. paddlex/inference/models/common/tokenizer/vocab.py +647 -0
  342. paddlex/inference/models/common/ts/__init__.py +15 -0
  343. paddlex/inference/models/common/ts/funcs.py +533 -0
  344. paddlex/inference/models/common/ts/processors.py +313 -0
  345. paddlex/inference/models/common/vision/__init__.py +23 -0
  346. paddlex/inference/models/common/vision/funcs.py +93 -0
  347. paddlex/inference/models/common/vision/processors.py +270 -0
  348. paddlex/inference/models/face_feature/__init__.py +15 -0
  349. paddlex/inference/models/face_feature/predictor.py +65 -0
  350. paddlex/inference/models/formula_recognition/__init__.py +15 -0
  351. paddlex/inference/models/formula_recognition/predictor.py +203 -0
  352. paddlex/inference/models/formula_recognition/processors.py +986 -0
  353. paddlex/inference/models/formula_recognition/result.py +403 -0
  354. paddlex/inference/models/image_classification/__init__.py +15 -0
  355. paddlex/inference/models/image_classification/predictor.py +182 -0
  356. paddlex/inference/models/image_classification/processors.py +87 -0
  357. paddlex/inference/models/image_classification/result.py +92 -0
  358. paddlex/inference/models/image_feature/__init__.py +15 -0
  359. paddlex/inference/models/image_feature/predictor.py +156 -0
  360. paddlex/inference/models/image_feature/processors.py +29 -0
  361. paddlex/inference/models/image_feature/result.py +33 -0
  362. paddlex/inference/models/image_multilabel_classification/__init__.py +15 -0
  363. paddlex/inference/models/image_multilabel_classification/predictor.py +94 -0
  364. paddlex/inference/models/image_multilabel_classification/processors.py +85 -0
  365. paddlex/inference/models/image_multilabel_classification/result.py +95 -0
  366. paddlex/inference/models/image_unwarping/__init__.py +15 -0
  367. paddlex/inference/models/image_unwarping/predictor.py +105 -0
  368. paddlex/inference/models/image_unwarping/processors.py +88 -0
  369. paddlex/inference/models/image_unwarping/result.py +45 -0
  370. paddlex/inference/models/instance_segmentation/__init__.py +15 -0
  371. paddlex/inference/models/instance_segmentation/predictor.py +210 -0
  372. paddlex/inference/models/instance_segmentation/processors.py +105 -0
  373. paddlex/inference/models/instance_segmentation/result.py +161 -0
  374. paddlex/inference/models/keypoint_detection/__init__.py +15 -0
  375. paddlex/inference/models/keypoint_detection/predictor.py +188 -0
  376. paddlex/inference/models/keypoint_detection/processors.py +359 -0
  377. paddlex/inference/models/keypoint_detection/result.py +192 -0
  378. paddlex/inference/models/multilingual_speech_recognition/__init__.py +15 -0
  379. paddlex/inference/models/multilingual_speech_recognition/predictor.py +141 -0
  380. paddlex/inference/models/multilingual_speech_recognition/processors.py +1941 -0
  381. paddlex/inference/models/multilingual_speech_recognition/result.py +21 -0
  382. paddlex/inference/models/object_detection/__init__.py +15 -0
  383. paddlex/inference/models/object_detection/predictor.py +348 -0
  384. paddlex/inference/models/object_detection/processors.py +855 -0
  385. paddlex/inference/models/object_detection/result.py +113 -0
  386. paddlex/inference/models/object_detection/utils.py +68 -0
  387. paddlex/inference/models/open_vocabulary_detection/__init__.py +15 -0
  388. paddlex/inference/models/open_vocabulary_detection/predictor.py +155 -0
  389. paddlex/inference/models/open_vocabulary_detection/processors/__init__.py +15 -0
  390. paddlex/inference/models/open_vocabulary_detection/processors/groundingdino_processors.py +485 -0
  391. paddlex/inference/models/open_vocabulary_segmentation/__init__.py +15 -0
  392. paddlex/inference/models/open_vocabulary_segmentation/predictor.py +120 -0
  393. paddlex/inference/models/open_vocabulary_segmentation/processors/__init__.py +15 -0
  394. paddlex/inference/models/open_vocabulary_segmentation/processors/sam_processer.py +249 -0
  395. paddlex/inference/models/open_vocabulary_segmentation/results/__init__.py +15 -0
  396. paddlex/inference/models/open_vocabulary_segmentation/results/sam_result.py +147 -0
  397. paddlex/inference/models/semantic_segmentation/__init__.py +15 -0
  398. paddlex/inference/models/semantic_segmentation/predictor.py +167 -0
  399. paddlex/inference/models/semantic_segmentation/processors.py +114 -0
  400. paddlex/inference/models/semantic_segmentation/result.py +72 -0
  401. paddlex/inference/models/table_structure_recognition/__init__.py +15 -0
  402. paddlex/inference/models/table_structure_recognition/predictor.py +171 -0
  403. paddlex/inference/models/table_structure_recognition/processors.py +235 -0
  404. paddlex/inference/models/table_structure_recognition/result.py +70 -0
  405. paddlex/inference/models/text_detection/__init__.py +15 -0
  406. paddlex/inference/models/text_detection/predictor.py +191 -0
  407. paddlex/inference/models/text_detection/processors.py +466 -0
  408. paddlex/inference/models/text_detection/result.py +51 -0
  409. paddlex/inference/models/text_recognition/__init__.py +15 -0
  410. paddlex/inference/models/text_recognition/predictor.py +106 -0
  411. paddlex/inference/models/text_recognition/processors.py +231 -0
  412. paddlex/inference/models/text_recognition/result.py +75 -0
  413. paddlex/inference/models/ts_anomaly_detection/__init__.py +15 -0
  414. paddlex/inference/models/ts_anomaly_detection/predictor.py +146 -0
  415. paddlex/inference/models/ts_anomaly_detection/processors.py +94 -0
  416. paddlex/inference/models/ts_anomaly_detection/result.py +72 -0
  417. paddlex/inference/models/ts_classification/__init__.py +15 -0
  418. paddlex/inference/models/ts_classification/predictor.py +135 -0
  419. paddlex/inference/models/ts_classification/processors.py +117 -0
  420. paddlex/inference/models/ts_classification/result.py +78 -0
  421. paddlex/inference/models/ts_forecasting/__init__.py +15 -0
  422. paddlex/inference/models/ts_forecasting/predictor.py +159 -0
  423. paddlex/inference/models/ts_forecasting/processors.py +149 -0
  424. paddlex/inference/models/ts_forecasting/result.py +83 -0
  425. paddlex/inference/models/video_classification/__init__.py +15 -0
  426. paddlex/inference/models/video_classification/predictor.py +147 -0
  427. paddlex/inference/models/video_classification/processors.py +409 -0
  428. paddlex/inference/models/video_classification/result.py +92 -0
  429. paddlex/inference/models/video_detection/__init__.py +15 -0
  430. paddlex/inference/models/video_detection/predictor.py +136 -0
  431. paddlex/inference/models/video_detection/processors.py +450 -0
  432. paddlex/inference/models/video_detection/result.py +104 -0
  433. paddlex/inference/pipelines/3d_bev_detection/__init__.py +15 -0
  434. paddlex/inference/pipelines/3d_bev_detection/pipeline.py +67 -0
  435. paddlex/inference/pipelines/__init__.py +228 -0
  436. paddlex/inference/pipelines/anomaly_detection/__init__.py +15 -0
  437. paddlex/inference/pipelines/anomaly_detection/pipeline.py +62 -0
  438. paddlex/inference/pipelines/attribute_recognition/__init__.py +15 -0
  439. paddlex/inference/pipelines/attribute_recognition/pipeline.py +105 -0
  440. paddlex/inference/pipelines/attribute_recognition/result.py +100 -0
  441. paddlex/inference/pipelines/base.py +132 -0
  442. paddlex/inference/pipelines/components/__init__.py +23 -0
  443. paddlex/inference/pipelines/components/chat_server/__init__.py +16 -0
  444. paddlex/inference/pipelines/components/chat_server/base.py +39 -0
  445. paddlex/inference/pipelines/components/chat_server/openai_bot_chat.py +236 -0
  446. paddlex/inference/pipelines/components/common/__init__.py +18 -0
  447. paddlex/inference/pipelines/components/common/base_operator.py +36 -0
  448. paddlex/inference/pipelines/components/common/base_result.py +65 -0
  449. paddlex/inference/pipelines/components/common/convert_points_and_boxes.py +46 -0
  450. paddlex/inference/pipelines/components/common/crop_image_regions.py +550 -0
  451. paddlex/inference/pipelines/components/common/seal_det_warp.py +941 -0
  452. paddlex/inference/pipelines/components/common/sort_boxes.py +83 -0
  453. paddlex/inference/pipelines/components/faisser.py +352 -0
  454. paddlex/inference/pipelines/components/prompt_engineering/__init__.py +16 -0
  455. paddlex/inference/pipelines/components/prompt_engineering/base.py +35 -0
  456. paddlex/inference/pipelines/components/prompt_engineering/generate_ensemble_prompt.py +127 -0
  457. paddlex/inference/pipelines/components/prompt_engineering/generate_kie_prompt.py +148 -0
  458. paddlex/inference/pipelines/components/retriever/__init__.py +16 -0
  459. paddlex/inference/pipelines/components/retriever/base.py +226 -0
  460. paddlex/inference/pipelines/components/retriever/openai_bot_retriever.py +70 -0
  461. paddlex/inference/pipelines/components/retriever/qianfan_bot_retriever.py +163 -0
  462. paddlex/inference/pipelines/components/utils/__init__.py +13 -0
  463. paddlex/inference/pipelines/components/utils/mixin.py +206 -0
  464. paddlex/inference/pipelines/doc_preprocessor/__init__.py +15 -0
  465. paddlex/inference/pipelines/doc_preprocessor/pipeline.py +190 -0
  466. paddlex/inference/pipelines/doc_preprocessor/result.py +103 -0
  467. paddlex/inference/pipelines/face_recognition/__init__.py +15 -0
  468. paddlex/inference/pipelines/face_recognition/pipeline.py +61 -0
  469. paddlex/inference/pipelines/face_recognition/result.py +43 -0
  470. paddlex/inference/pipelines/formula_recognition/__init__.py +15 -0
  471. paddlex/inference/pipelines/formula_recognition/pipeline.py +303 -0
  472. paddlex/inference/pipelines/formula_recognition/result.py +291 -0
  473. paddlex/inference/pipelines/image_classification/__init__.py +15 -0
  474. paddlex/inference/pipelines/image_classification/pipeline.py +71 -0
  475. paddlex/inference/pipelines/image_multilabel_classification/__init__.py +15 -0
  476. paddlex/inference/pipelines/image_multilabel_classification/pipeline.py +78 -0
  477. paddlex/inference/pipelines/instance_segmentation/__init__.py +15 -0
  478. paddlex/inference/pipelines/instance_segmentation/pipeline.py +70 -0
  479. paddlex/inference/pipelines/keypoint_detection/__init__.py +15 -0
  480. paddlex/inference/pipelines/keypoint_detection/pipeline.py +137 -0
  481. paddlex/inference/pipelines/layout_parsing/__init__.py +16 -0
  482. paddlex/inference/pipelines/layout_parsing/pipeline.py +570 -0
  483. paddlex/inference/pipelines/layout_parsing/pipeline_v2.py +739 -0
  484. paddlex/inference/pipelines/layout_parsing/result.py +203 -0
  485. paddlex/inference/pipelines/layout_parsing/result_v2.py +470 -0
  486. paddlex/inference/pipelines/layout_parsing/utils.py +2385 -0
  487. paddlex/inference/pipelines/multilingual_speech_recognition/__init__.py +15 -0
  488. paddlex/inference/pipelines/multilingual_speech_recognition/pipeline.py +67 -0
  489. paddlex/inference/pipelines/object_detection/__init__.py +15 -0
  490. paddlex/inference/pipelines/object_detection/pipeline.py +95 -0
  491. paddlex/inference/pipelines/ocr/__init__.py +15 -0
  492. paddlex/inference/pipelines/ocr/pipeline.py +389 -0
  493. paddlex/inference/pipelines/ocr/result.py +248 -0
  494. paddlex/inference/pipelines/open_vocabulary_detection/__init__.py +15 -0
  495. paddlex/inference/pipelines/open_vocabulary_detection/pipeline.py +75 -0
  496. paddlex/inference/pipelines/open_vocabulary_segmentation/__init__.py +15 -0
  497. paddlex/inference/pipelines/open_vocabulary_segmentation/pipeline.py +89 -0
  498. paddlex/inference/pipelines/pp_chatocr/__init__.py +16 -0
  499. paddlex/inference/pipelines/pp_chatocr/pipeline_base.py +102 -0
  500. paddlex/inference/pipelines/pp_chatocr/pipeline_v3.py +773 -0
  501. paddlex/inference/pipelines/pp_chatocr/pipeline_v4.py +977 -0
  502. paddlex/inference/pipelines/pp_shitu_v2/__init__.py +15 -0
  503. paddlex/inference/pipelines/pp_shitu_v2/pipeline.py +152 -0
  504. paddlex/inference/pipelines/pp_shitu_v2/result.py +126 -0
  505. paddlex/inference/pipelines/rotated_object_detection/__init__.py +15 -0
  506. paddlex/inference/pipelines/rotated_object_detection/pipeline.py +74 -0
  507. paddlex/inference/pipelines/seal_recognition/__init__.py +15 -0
  508. paddlex/inference/pipelines/seal_recognition/pipeline.py +271 -0
  509. paddlex/inference/pipelines/seal_recognition/result.py +87 -0
  510. paddlex/inference/pipelines/semantic_segmentation/__init__.py +15 -0
  511. paddlex/inference/pipelines/semantic_segmentation/pipeline.py +74 -0
  512. paddlex/inference/pipelines/small_object_detection/__init__.py +15 -0
  513. paddlex/inference/pipelines/small_object_detection/pipeline.py +74 -0
  514. paddlex/inference/pipelines/table_recognition/__init__.py +16 -0
  515. paddlex/inference/pipelines/table_recognition/pipeline.py +462 -0
  516. paddlex/inference/pipelines/table_recognition/pipeline_v2.py +792 -0
  517. paddlex/inference/pipelines/table_recognition/result.py +216 -0
  518. paddlex/inference/pipelines/table_recognition/table_recognition_post_processing.py +362 -0
  519. paddlex/inference/pipelines/table_recognition/table_recognition_post_processing_v2.py +470 -0
  520. paddlex/inference/pipelines/table_recognition/utils.py +44 -0
  521. paddlex/inference/pipelines/ts_anomaly_detection/__init__.py +15 -0
  522. paddlex/inference/pipelines/ts_anomaly_detection/pipeline.py +62 -0
  523. paddlex/inference/pipelines/ts_classification/__init__.py +15 -0
  524. paddlex/inference/pipelines/ts_classification/pipeline.py +62 -0
  525. paddlex/inference/pipelines/ts_forecasting/__init__.py +15 -0
  526. paddlex/inference/pipelines/ts_forecasting/pipeline.py +62 -0
  527. paddlex/inference/pipelines/video_classification/__init__.py +15 -0
  528. paddlex/inference/pipelines/video_classification/pipeline.py +68 -0
  529. paddlex/inference/pipelines/video_detection/__init__.py +15 -0
  530. paddlex/inference/pipelines/video_detection/pipeline.py +73 -0
  531. paddlex/inference/serving/__init__.py +13 -0
  532. paddlex/inference/serving/basic_serving/__init__.py +18 -0
  533. paddlex/inference/serving/basic_serving/_app.py +209 -0
  534. paddlex/inference/serving/basic_serving/_pipeline_apps/__init__.py +41 -0
  535. paddlex/inference/serving/basic_serving/_pipeline_apps/_common/__init__.py +13 -0
  536. paddlex/inference/serving/basic_serving/_pipeline_apps/_common/common.py +96 -0
  537. paddlex/inference/serving/basic_serving/_pipeline_apps/_common/image_recognition.py +36 -0
  538. paddlex/inference/serving/basic_serving/_pipeline_apps/_common/ocr.py +90 -0
  539. paddlex/inference/serving/basic_serving/_pipeline_apps/anomaly_detection.py +64 -0
  540. paddlex/inference/serving/basic_serving/_pipeline_apps/doc_preprocessor.py +97 -0
  541. paddlex/inference/serving/basic_serving/_pipeline_apps/face_recognition.py +223 -0
  542. paddlex/inference/serving/basic_serving/_pipeline_apps/formula_recognition.py +97 -0
  543. paddlex/inference/serving/basic_serving/_pipeline_apps/human_keypoint_detection.py +78 -0
  544. paddlex/inference/serving/basic_serving/_pipeline_apps/image_classification.py +66 -0
  545. paddlex/inference/serving/basic_serving/_pipeline_apps/image_multilabel_classification.py +70 -0
  546. paddlex/inference/serving/basic_serving/_pipeline_apps/instance_segmentation.py +81 -0
  547. paddlex/inference/serving/basic_serving/_pipeline_apps/layout_parsing.py +115 -0
  548. paddlex/inference/serving/basic_serving/_pipeline_apps/m_3d_bev_detection.py +76 -0
  549. paddlex/inference/serving/basic_serving/_pipeline_apps/multilingual_speech_recognition.py +89 -0
  550. paddlex/inference/serving/basic_serving/_pipeline_apps/object_detection.py +74 -0
  551. paddlex/inference/serving/basic_serving/_pipeline_apps/ocr.py +99 -0
  552. paddlex/inference/serving/basic_serving/_pipeline_apps/open_vocabulary_detection.py +78 -0
  553. paddlex/inference/serving/basic_serving/_pipeline_apps/open_vocabulary_segmentation.py +85 -0
  554. paddlex/inference/serving/basic_serving/_pipeline_apps/pedestrian_attribute_recognition.py +81 -0
  555. paddlex/inference/serving/basic_serving/_pipeline_apps/pp_chatocrv3_doc.py +191 -0
  556. paddlex/inference/serving/basic_serving/_pipeline_apps/pp_chatocrv4_doc.py +221 -0
  557. paddlex/inference/serving/basic_serving/_pipeline_apps/pp_shituv2.py +218 -0
  558. paddlex/inference/serving/basic_serving/_pipeline_apps/pp_structurev3.py +136 -0
  559. paddlex/inference/serving/basic_serving/_pipeline_apps/rotated_object_detection.py +78 -0
  560. paddlex/inference/serving/basic_serving/_pipeline_apps/seal_recognition.py +103 -0
  561. paddlex/inference/serving/basic_serving/_pipeline_apps/semantic_segmentation.py +64 -0
  562. paddlex/inference/serving/basic_serving/_pipeline_apps/small_object_detection.py +69 -0
  563. paddlex/inference/serving/basic_serving/_pipeline_apps/table_recognition.py +105 -0
  564. paddlex/inference/serving/basic_serving/_pipeline_apps/table_recognition_v2.py +107 -0
  565. paddlex/inference/serving/basic_serving/_pipeline_apps/ts_anomaly_detection.py +62 -0
  566. paddlex/inference/serving/basic_serving/_pipeline_apps/ts_classification.py +61 -0
  567. paddlex/inference/serving/basic_serving/_pipeline_apps/ts_forecast.py +62 -0
  568. paddlex/inference/serving/basic_serving/_pipeline_apps/vehicle_attribute_recognition.py +81 -0
  569. paddlex/inference/serving/basic_serving/_pipeline_apps/video_classification.py +73 -0
  570. paddlex/inference/serving/basic_serving/_pipeline_apps/video_detection.py +89 -0
  571. paddlex/inference/serving/basic_serving/_server.py +35 -0
  572. paddlex/inference/serving/infra/__init__.py +13 -0
  573. paddlex/inference/serving/infra/config.py +36 -0
  574. paddlex/inference/serving/infra/models.py +72 -0
  575. paddlex/inference/serving/infra/storage.py +175 -0
  576. paddlex/inference/serving/infra/utils.py +259 -0
  577. paddlex/inference/serving/schemas/__init__.py +13 -0
  578. paddlex/inference/serving/schemas/anomaly_detection.py +39 -0
  579. paddlex/inference/serving/schemas/doc_preprocessor.py +54 -0
  580. paddlex/inference/serving/schemas/face_recognition.py +124 -0
  581. paddlex/inference/serving/schemas/formula_recognition.py +56 -0
  582. paddlex/inference/serving/schemas/human_keypoint_detection.py +55 -0
  583. paddlex/inference/serving/schemas/image_classification.py +45 -0
  584. paddlex/inference/serving/schemas/image_multilabel_classification.py +47 -0
  585. paddlex/inference/serving/schemas/instance_segmentation.py +53 -0
  586. paddlex/inference/serving/schemas/layout_parsing.py +72 -0
  587. paddlex/inference/serving/schemas/m_3d_bev_detection.py +48 -0
  588. paddlex/inference/serving/schemas/multilingual_speech_recognition.py +57 -0
  589. paddlex/inference/serving/schemas/object_detection.py +52 -0
  590. paddlex/inference/serving/schemas/ocr.py +60 -0
  591. paddlex/inference/serving/schemas/open_vocabulary_detection.py +52 -0
  592. paddlex/inference/serving/schemas/open_vocabulary_segmentation.py +52 -0
  593. paddlex/inference/serving/schemas/pedestrian_attribute_recognition.py +61 -0
  594. paddlex/inference/serving/schemas/pp_chatocrv3_doc.py +134 -0
  595. paddlex/inference/serving/schemas/pp_chatocrv4_doc.py +151 -0
  596. paddlex/inference/serving/schemas/pp_shituv2.py +124 -0
  597. paddlex/inference/serving/schemas/pp_structurev3.py +84 -0
  598. paddlex/inference/serving/schemas/rotated_object_detection.py +52 -0
  599. paddlex/inference/serving/schemas/seal_recognition.py +62 -0
  600. paddlex/inference/serving/schemas/semantic_segmentation.py +45 -0
  601. paddlex/inference/serving/schemas/shared/__init__.py +13 -0
  602. paddlex/inference/serving/schemas/shared/classification.py +23 -0
  603. paddlex/inference/serving/schemas/shared/image_segmentation.py +28 -0
  604. paddlex/inference/serving/schemas/shared/object_detection.py +24 -0
  605. paddlex/inference/serving/schemas/shared/ocr.py +25 -0
  606. paddlex/inference/serving/schemas/small_object_detection.py +52 -0
  607. paddlex/inference/serving/schemas/table_recognition.py +64 -0
  608. paddlex/inference/serving/schemas/table_recognition_v2.py +66 -0
  609. paddlex/inference/serving/schemas/ts_anomaly_detection.py +37 -0
  610. paddlex/inference/serving/schemas/ts_classification.py +38 -0
  611. paddlex/inference/serving/schemas/ts_forecast.py +37 -0
  612. paddlex/inference/serving/schemas/vehicle_attribute_recognition.py +61 -0
  613. paddlex/inference/serving/schemas/video_classification.py +44 -0
  614. paddlex/inference/serving/schemas/video_detection.py +56 -0
  615. paddlex/inference/utils/__init__.py +13 -0
  616. paddlex/inference/utils/benchmark.py +226 -0
  617. paddlex/inference/utils/color_map.py +123 -0
  618. paddlex/inference/utils/get_pipeline_path.py +27 -0
  619. paddlex/inference/utils/io/__init__.py +36 -0
  620. paddlex/inference/utils/io/readers.py +500 -0
  621. paddlex/inference/utils/io/style.py +374 -0
  622. paddlex/inference/utils/io/tablepyxl.py +149 -0
  623. paddlex/inference/utils/io/writers.py +459 -0
  624. paddlex/inference/utils/new_ir_blacklist.py +28 -0
  625. paddlex/inference/utils/official_models.py +352 -0
  626. paddlex/inference/utils/pp_option.py +256 -0
  627. paddlex/model.py +113 -0
  628. paddlex/modules/3d_bev_detection/__init__.py +18 -0
  629. paddlex/modules/3d_bev_detection/dataset_checker/__init__.py +95 -0
  630. paddlex/modules/3d_bev_detection/dataset_checker/dataset_src/__init__.py +17 -0
  631. paddlex/modules/3d_bev_detection/dataset_checker/dataset_src/analyse_dataset.py +106 -0
  632. paddlex/modules/3d_bev_detection/dataset_checker/dataset_src/check_dataset.py +102 -0
  633. paddlex/modules/3d_bev_detection/evaluator.py +46 -0
  634. paddlex/modules/3d_bev_detection/exportor.py +22 -0
  635. paddlex/modules/3d_bev_detection/model_list.py +18 -0
  636. paddlex/modules/3d_bev_detection/trainer.py +70 -0
  637. paddlex/modules/__init__.py +138 -0
  638. paddlex/modules/anomaly_detection/__init__.py +18 -0
  639. paddlex/modules/anomaly_detection/dataset_checker/__init__.py +95 -0
  640. paddlex/modules/anomaly_detection/dataset_checker/dataset_src/__init__.py +19 -0
  641. paddlex/modules/anomaly_detection/dataset_checker/dataset_src/analyse_dataset.py +79 -0
  642. paddlex/modules/anomaly_detection/dataset_checker/dataset_src/check_dataset.py +87 -0
  643. paddlex/modules/anomaly_detection/dataset_checker/dataset_src/convert_dataset.py +230 -0
  644. paddlex/modules/anomaly_detection/dataset_checker/dataset_src/split_dataset.py +87 -0
  645. paddlex/modules/anomaly_detection/dataset_checker/dataset_src/utils/__init__.py +13 -0
  646. paddlex/modules/anomaly_detection/dataset_checker/dataset_src/utils/visualizer.py +71 -0
  647. paddlex/modules/anomaly_detection/evaluator.py +58 -0
  648. paddlex/modules/anomaly_detection/exportor.py +22 -0
  649. paddlex/modules/anomaly_detection/model_list.py +16 -0
  650. paddlex/modules/anomaly_detection/trainer.py +71 -0
  651. paddlex/modules/base/__init__.py +18 -0
  652. paddlex/modules/base/build_model.py +34 -0
  653. paddlex/modules/base/dataset_checker/__init__.py +16 -0
  654. paddlex/modules/base/dataset_checker/dataset_checker.py +169 -0
  655. paddlex/modules/base/dataset_checker/utils.py +110 -0
  656. paddlex/modules/base/evaluator.py +170 -0
  657. paddlex/modules/base/exportor.py +146 -0
  658. paddlex/modules/base/trainer.py +134 -0
  659. paddlex/modules/face_recognition/__init__.py +18 -0
  660. paddlex/modules/face_recognition/dataset_checker/__init__.py +71 -0
  661. paddlex/modules/face_recognition/dataset_checker/dataset_src/__init__.py +16 -0
  662. paddlex/modules/face_recognition/dataset_checker/dataset_src/check_dataset.py +174 -0
  663. paddlex/modules/face_recognition/dataset_checker/dataset_src/utils/__init__.py +13 -0
  664. paddlex/modules/face_recognition/dataset_checker/dataset_src/utils/visualizer.py +156 -0
  665. paddlex/modules/face_recognition/evaluator.py +52 -0
  666. paddlex/modules/face_recognition/exportor.py +22 -0
  667. paddlex/modules/face_recognition/model_list.py +15 -0
  668. paddlex/modules/face_recognition/trainer.py +75 -0
  669. paddlex/modules/formula_recognition/__init__.py +18 -0
  670. paddlex/modules/formula_recognition/dataset_checker/__init__.py +113 -0
  671. paddlex/modules/formula_recognition/dataset_checker/dataset_src/__init__.py +19 -0
  672. paddlex/modules/formula_recognition/dataset_checker/dataset_src/analyse_dataset.py +157 -0
  673. paddlex/modules/formula_recognition/dataset_checker/dataset_src/check_dataset.py +80 -0
  674. paddlex/modules/formula_recognition/dataset_checker/dataset_src/convert_dataset.py +94 -0
  675. paddlex/modules/formula_recognition/dataset_checker/dataset_src/split_dataset.py +81 -0
  676. paddlex/modules/formula_recognition/evaluator.py +77 -0
  677. paddlex/modules/formula_recognition/exportor.py +22 -0
  678. paddlex/modules/formula_recognition/model_list.py +20 -0
  679. paddlex/modules/formula_recognition/trainer.py +121 -0
  680. paddlex/modules/general_recognition/__init__.py +18 -0
  681. paddlex/modules/general_recognition/dataset_checker/__init__.py +107 -0
  682. paddlex/modules/general_recognition/dataset_checker/dataset_src/__init__.py +19 -0
  683. paddlex/modules/general_recognition/dataset_checker/dataset_src/analyse_dataset.py +98 -0
  684. paddlex/modules/general_recognition/dataset_checker/dataset_src/check_dataset.py +100 -0
  685. paddlex/modules/general_recognition/dataset_checker/dataset_src/convert_dataset.py +99 -0
  686. paddlex/modules/general_recognition/dataset_checker/dataset_src/split_dataset.py +82 -0
  687. paddlex/modules/general_recognition/dataset_checker/dataset_src/utils/__init__.py +13 -0
  688. paddlex/modules/general_recognition/dataset_checker/dataset_src/utils/visualizer.py +150 -0
  689. paddlex/modules/general_recognition/evaluator.py +31 -0
  690. paddlex/modules/general_recognition/exportor.py +22 -0
  691. paddlex/modules/general_recognition/model_list.py +19 -0
  692. paddlex/modules/general_recognition/trainer.py +52 -0
  693. paddlex/modules/image_classification/__init__.py +18 -0
  694. paddlex/modules/image_classification/dataset_checker/__init__.py +104 -0
  695. paddlex/modules/image_classification/dataset_checker/dataset_src/__init__.py +19 -0
  696. paddlex/modules/image_classification/dataset_checker/dataset_src/analyse_dataset.py +93 -0
  697. paddlex/modules/image_classification/dataset_checker/dataset_src/check_dataset.py +131 -0
  698. paddlex/modules/image_classification/dataset_checker/dataset_src/convert_dataset.py +51 -0
  699. paddlex/modules/image_classification/dataset_checker/dataset_src/split_dataset.py +81 -0
  700. paddlex/modules/image_classification/dataset_checker/dataset_src/utils/__init__.py +13 -0
  701. paddlex/modules/image_classification/dataset_checker/dataset_src/utils/visualizer.py +156 -0
  702. paddlex/modules/image_classification/evaluator.py +43 -0
  703. paddlex/modules/image_classification/exportor.py +22 -0
  704. paddlex/modules/image_classification/model_list.py +99 -0
  705. paddlex/modules/image_classification/trainer.py +82 -0
  706. paddlex/modules/image_unwarping/__init__.py +13 -0
  707. paddlex/modules/image_unwarping/model_list.py +17 -0
  708. paddlex/modules/instance_segmentation/__init__.py +18 -0
  709. paddlex/modules/instance_segmentation/dataset_checker/__init__.py +108 -0
  710. paddlex/modules/instance_segmentation/dataset_checker/dataset_src/__init__.py +19 -0
  711. paddlex/modules/instance_segmentation/dataset_checker/dataset_src/analyse_dataset.py +78 -0
  712. paddlex/modules/instance_segmentation/dataset_checker/dataset_src/check_dataset.py +92 -0
  713. paddlex/modules/instance_segmentation/dataset_checker/dataset_src/convert_dataset.py +241 -0
  714. paddlex/modules/instance_segmentation/dataset_checker/dataset_src/split_dataset.py +119 -0
  715. paddlex/modules/instance_segmentation/dataset_checker/dataset_src/utils/__init__.py +13 -0
  716. paddlex/modules/instance_segmentation/dataset_checker/dataset_src/utils/visualizer.py +221 -0
  717. paddlex/modules/instance_segmentation/evaluator.py +32 -0
  718. paddlex/modules/instance_segmentation/exportor.py +22 -0
  719. paddlex/modules/instance_segmentation/model_list.py +33 -0
  720. paddlex/modules/instance_segmentation/trainer.py +31 -0
  721. paddlex/modules/keypoint_detection/__init__.py +18 -0
  722. paddlex/modules/keypoint_detection/dataset_checker/__init__.py +56 -0
  723. paddlex/modules/keypoint_detection/dataset_checker/dataset_src/__init__.py +15 -0
  724. paddlex/modules/keypoint_detection/dataset_checker/dataset_src/check_dataset.py +86 -0
  725. paddlex/modules/keypoint_detection/dataset_checker/dataset_src/utils/__init__.py +13 -0
  726. paddlex/modules/keypoint_detection/dataset_checker/dataset_src/utils/visualizer.py +119 -0
  727. paddlex/modules/keypoint_detection/evaluator.py +41 -0
  728. paddlex/modules/keypoint_detection/exportor.py +22 -0
  729. paddlex/modules/keypoint_detection/model_list.py +16 -0
  730. paddlex/modules/keypoint_detection/trainer.py +39 -0
  731. paddlex/modules/multilabel_classification/__init__.py +18 -0
  732. paddlex/modules/multilabel_classification/dataset_checker/__init__.py +106 -0
  733. paddlex/modules/multilabel_classification/dataset_checker/dataset_src/__init__.py +19 -0
  734. paddlex/modules/multilabel_classification/dataset_checker/dataset_src/analyse_dataset.py +95 -0
  735. paddlex/modules/multilabel_classification/dataset_checker/dataset_src/check_dataset.py +131 -0
  736. paddlex/modules/multilabel_classification/dataset_checker/dataset_src/convert_dataset.py +117 -0
  737. paddlex/modules/multilabel_classification/dataset_checker/dataset_src/split_dataset.py +81 -0
  738. paddlex/modules/multilabel_classification/dataset_checker/dataset_src/utils/__init__.py +13 -0
  739. paddlex/modules/multilabel_classification/dataset_checker/dataset_src/utils/visualizer.py +153 -0
  740. paddlex/modules/multilabel_classification/evaluator.py +43 -0
  741. paddlex/modules/multilabel_classification/exportor.py +22 -0
  742. paddlex/modules/multilabel_classification/model_list.py +24 -0
  743. paddlex/modules/multilabel_classification/trainer.py +85 -0
  744. paddlex/modules/multilingual_speech_recognition/__init__.py +18 -0
  745. paddlex/modules/multilingual_speech_recognition/dataset_checker.py +27 -0
  746. paddlex/modules/multilingual_speech_recognition/evaluator.py +27 -0
  747. paddlex/modules/multilingual_speech_recognition/exportor.py +27 -0
  748. paddlex/modules/multilingual_speech_recognition/model_list.py +22 -0
  749. paddlex/modules/multilingual_speech_recognition/trainer.py +40 -0
  750. paddlex/modules/object_detection/__init__.py +18 -0
  751. paddlex/modules/object_detection/dataset_checker/__init__.py +115 -0
  752. paddlex/modules/object_detection/dataset_checker/dataset_src/__init__.py +19 -0
  753. paddlex/modules/object_detection/dataset_checker/dataset_src/analyse_dataset.py +80 -0
  754. paddlex/modules/object_detection/dataset_checker/dataset_src/check_dataset.py +86 -0
  755. paddlex/modules/object_detection/dataset_checker/dataset_src/convert_dataset.py +433 -0
  756. paddlex/modules/object_detection/dataset_checker/dataset_src/split_dataset.py +119 -0
  757. paddlex/modules/object_detection/dataset_checker/dataset_src/utils/__init__.py +13 -0
  758. paddlex/modules/object_detection/dataset_checker/dataset_src/utils/visualizer.py +192 -0
  759. paddlex/modules/object_detection/evaluator.py +52 -0
  760. paddlex/modules/object_detection/exportor.py +22 -0
  761. paddlex/modules/object_detection/model_list.py +84 -0
  762. paddlex/modules/object_detection/trainer.py +99 -0
  763. paddlex/modules/open_vocabulary_detection/__init__.py +18 -0
  764. paddlex/modules/open_vocabulary_detection/dataset_checker.py +29 -0
  765. paddlex/modules/open_vocabulary_detection/evaluator.py +29 -0
  766. paddlex/modules/open_vocabulary_detection/exportor.py +29 -0
  767. paddlex/modules/open_vocabulary_detection/model_list.py +18 -0
  768. paddlex/modules/open_vocabulary_detection/trainer.py +42 -0
  769. paddlex/modules/open_vocabulary_segmentation/__init__.py +18 -0
  770. paddlex/modules/open_vocabulary_segmentation/dataset_checker.py +29 -0
  771. paddlex/modules/open_vocabulary_segmentation/evaluator.py +29 -0
  772. paddlex/modules/open_vocabulary_segmentation/exportor.py +29 -0
  773. paddlex/modules/open_vocabulary_segmentation/model_list.py +19 -0
  774. paddlex/modules/open_vocabulary_segmentation/trainer.py +42 -0
  775. paddlex/modules/semantic_segmentation/__init__.py +18 -0
  776. paddlex/modules/semantic_segmentation/dataset_checker/__init__.py +110 -0
  777. paddlex/modules/semantic_segmentation/dataset_checker/dataset_src/__init__.py +19 -0
  778. paddlex/modules/semantic_segmentation/dataset_checker/dataset_src/analyse_dataset.py +73 -0
  779. paddlex/modules/semantic_segmentation/dataset_checker/dataset_src/check_dataset.py +80 -0
  780. paddlex/modules/semantic_segmentation/dataset_checker/dataset_src/convert_dataset.py +162 -0
  781. paddlex/modules/semantic_segmentation/dataset_checker/dataset_src/split_dataset.py +87 -0
  782. paddlex/modules/semantic_segmentation/dataset_checker/dataset_src/utils/__init__.py +13 -0
  783. paddlex/modules/semantic_segmentation/dataset_checker/dataset_src/utils/visualizer.py +71 -0
  784. paddlex/modules/semantic_segmentation/evaluator.py +58 -0
  785. paddlex/modules/semantic_segmentation/exportor.py +31 -0
  786. paddlex/modules/semantic_segmentation/model_list.py +37 -0
  787. paddlex/modules/semantic_segmentation/trainer.py +73 -0
  788. paddlex/modules/table_recognition/__init__.py +18 -0
  789. paddlex/modules/table_recognition/dataset_checker/__init__.py +98 -0
  790. paddlex/modules/table_recognition/dataset_checker/dataset_src/__init__.py +18 -0
  791. paddlex/modules/table_recognition/dataset_checker/dataset_src/analyse_dataset.py +58 -0
  792. paddlex/modules/table_recognition/dataset_checker/dataset_src/check_dataset.py +86 -0
  793. paddlex/modules/table_recognition/dataset_checker/dataset_src/split_dataset.py +79 -0
  794. paddlex/modules/table_recognition/evaluator.py +43 -0
  795. paddlex/modules/table_recognition/exportor.py +22 -0
  796. paddlex/modules/table_recognition/model_list.py +21 -0
  797. paddlex/modules/table_recognition/trainer.py +70 -0
  798. paddlex/modules/text_detection/__init__.py +18 -0
  799. paddlex/modules/text_detection/dataset_checker/__init__.py +109 -0
  800. paddlex/modules/text_detection/dataset_checker/dataset_src/__init__.py +18 -0
  801. paddlex/modules/text_detection/dataset_checker/dataset_src/analyse_dataset.py +217 -0
  802. paddlex/modules/text_detection/dataset_checker/dataset_src/check_dataset.py +106 -0
  803. paddlex/modules/text_detection/dataset_checker/dataset_src/split_dataset.py +140 -0
  804. paddlex/modules/text_detection/evaluator.py +41 -0
  805. paddlex/modules/text_detection/exportor.py +22 -0
  806. paddlex/modules/text_detection/model_list.py +24 -0
  807. paddlex/modules/text_detection/trainer.py +68 -0
  808. paddlex/modules/text_recognition/__init__.py +18 -0
  809. paddlex/modules/text_recognition/dataset_checker/__init__.py +126 -0
  810. paddlex/modules/text_recognition/dataset_checker/dataset_src/__init__.py +19 -0
  811. paddlex/modules/text_recognition/dataset_checker/dataset_src/analyse_dataset.py +161 -0
  812. paddlex/modules/text_recognition/dataset_checker/dataset_src/check_dataset.py +107 -0
  813. paddlex/modules/text_recognition/dataset_checker/dataset_src/convert_dataset.py +94 -0
  814. paddlex/modules/text_recognition/dataset_checker/dataset_src/split_dataset.py +81 -0
  815. paddlex/modules/text_recognition/evaluator.py +64 -0
  816. paddlex/modules/text_recognition/exportor.py +22 -0
  817. paddlex/modules/text_recognition/model_list.py +34 -0
  818. paddlex/modules/text_recognition/trainer.py +106 -0
  819. paddlex/modules/ts_anomaly_detection/__init__.py +19 -0
  820. paddlex/modules/ts_anomaly_detection/dataset_checker/__init__.py +112 -0
  821. paddlex/modules/ts_anomaly_detection/dataset_checker/dataset_src/__init__.py +19 -0
  822. paddlex/modules/ts_anomaly_detection/dataset_checker/dataset_src/analyse_dataset.py +27 -0
  823. paddlex/modules/ts_anomaly_detection/dataset_checker/dataset_src/check_dataset.py +64 -0
  824. paddlex/modules/ts_anomaly_detection/dataset_checker/dataset_src/convert_dataset.py +78 -0
  825. paddlex/modules/ts_anomaly_detection/dataset_checker/dataset_src/split_dataset.py +63 -0
  826. paddlex/modules/ts_anomaly_detection/evaluator.py +67 -0
  827. paddlex/modules/ts_anomaly_detection/exportor.py +45 -0
  828. paddlex/modules/ts_anomaly_detection/model_list.py +22 -0
  829. paddlex/modules/ts_anomaly_detection/trainer.py +113 -0
  830. paddlex/modules/ts_classification/__init__.py +19 -0
  831. paddlex/modules/ts_classification/dataset_checker/__init__.py +112 -0
  832. paddlex/modules/ts_classification/dataset_checker/dataset_src/__init__.py +19 -0
  833. paddlex/modules/ts_classification/dataset_checker/dataset_src/analyse_dataset.py +74 -0
  834. paddlex/modules/ts_classification/dataset_checker/dataset_src/check_dataset.py +64 -0
  835. paddlex/modules/ts_classification/dataset_checker/dataset_src/convert_dataset.py +78 -0
  836. paddlex/modules/ts_classification/dataset_checker/dataset_src/split_dataset.py +88 -0
  837. paddlex/modules/ts_classification/evaluator.py +66 -0
  838. paddlex/modules/ts_classification/exportor.py +45 -0
  839. paddlex/modules/ts_classification/model_list.py +18 -0
  840. paddlex/modules/ts_classification/trainer.py +108 -0
  841. paddlex/modules/ts_forecast/__init__.py +19 -0
  842. paddlex/modules/ts_forecast/dataset_checker/__init__.py +112 -0
  843. paddlex/modules/ts_forecast/dataset_checker/dataset_src/__init__.py +19 -0
  844. paddlex/modules/ts_forecast/dataset_checker/dataset_src/analyse_dataset.py +27 -0
  845. paddlex/modules/ts_forecast/dataset_checker/dataset_src/check_dataset.py +64 -0
  846. paddlex/modules/ts_forecast/dataset_checker/dataset_src/convert_dataset.py +77 -0
  847. paddlex/modules/ts_forecast/dataset_checker/dataset_src/split_dataset.py +63 -0
  848. paddlex/modules/ts_forecast/evaluator.py +66 -0
  849. paddlex/modules/ts_forecast/exportor.py +45 -0
  850. paddlex/modules/ts_forecast/model_list.py +24 -0
  851. paddlex/modules/ts_forecast/trainer.py +108 -0
  852. paddlex/modules/video_classification/__init__.py +18 -0
  853. paddlex/modules/video_classification/dataset_checker/__init__.py +93 -0
  854. paddlex/modules/video_classification/dataset_checker/dataset_src/__init__.py +18 -0
  855. paddlex/modules/video_classification/dataset_checker/dataset_src/analyse_dataset.py +93 -0
  856. paddlex/modules/video_classification/dataset_checker/dataset_src/check_dataset.py +121 -0
  857. paddlex/modules/video_classification/dataset_checker/dataset_src/split_dataset.py +82 -0
  858. paddlex/modules/video_classification/evaluator.py +44 -0
  859. paddlex/modules/video_classification/exportor.py +22 -0
  860. paddlex/modules/video_classification/model_list.py +19 -0
  861. paddlex/modules/video_classification/trainer.py +88 -0
  862. paddlex/modules/video_detection/__init__.py +18 -0
  863. paddlex/modules/video_detection/dataset_checker/__init__.py +86 -0
  864. paddlex/modules/video_detection/dataset_checker/dataset_src/__init__.py +17 -0
  865. paddlex/modules/video_detection/dataset_checker/dataset_src/analyse_dataset.py +101 -0
  866. paddlex/modules/video_detection/dataset_checker/dataset_src/check_dataset.py +134 -0
  867. paddlex/modules/video_detection/evaluator.py +42 -0
  868. paddlex/modules/video_detection/exportor.py +22 -0
  869. paddlex/modules/video_detection/model_list.py +15 -0
  870. paddlex/modules/video_detection/trainer.py +82 -0
  871. paddlex/ops/__init__.py +149 -0
  872. paddlex/ops/iou3d_nms/iou3d_cpu.cpp +264 -0
  873. paddlex/ops/iou3d_nms/iou3d_cpu.h +27 -0
  874. paddlex/ops/iou3d_nms/iou3d_nms.cpp +204 -0
  875. paddlex/ops/iou3d_nms/iou3d_nms.h +33 -0
  876. paddlex/ops/iou3d_nms/iou3d_nms_api.cpp +108 -0
  877. paddlex/ops/iou3d_nms/iou3d_nms_kernel.cu +482 -0
  878. paddlex/ops/setup.py +37 -0
  879. paddlex/ops/voxel/voxelize_op.cc +191 -0
  880. paddlex/ops/voxel/voxelize_op.cu +346 -0
  881. paddlex/paddle2onnx_requirements.txt +1 -0
  882. paddlex/paddlex_cli.py +464 -0
  883. paddlex/repo_apis/Paddle3D_api/__init__.py +17 -0
  884. paddlex/repo_apis/Paddle3D_api/bev_fusion/__init__.py +18 -0
  885. paddlex/repo_apis/Paddle3D_api/bev_fusion/config.py +118 -0
  886. paddlex/repo_apis/Paddle3D_api/bev_fusion/model.py +238 -0
  887. paddlex/repo_apis/Paddle3D_api/bev_fusion/register.py +55 -0
  888. paddlex/repo_apis/Paddle3D_api/bev_fusion/runner.py +104 -0
  889. paddlex/repo_apis/Paddle3D_api/pp3d_config.py +144 -0
  890. paddlex/repo_apis/PaddleClas_api/__init__.py +17 -0
  891. paddlex/repo_apis/PaddleClas_api/cls/__init__.py +19 -0
  892. paddlex/repo_apis/PaddleClas_api/cls/config.py +594 -0
  893. paddlex/repo_apis/PaddleClas_api/cls/model.py +355 -0
  894. paddlex/repo_apis/PaddleClas_api/cls/register.py +908 -0
  895. paddlex/repo_apis/PaddleClas_api/cls/runner.py +219 -0
  896. paddlex/repo_apis/PaddleClas_api/shitu_rec/__init__.py +18 -0
  897. paddlex/repo_apis/PaddleClas_api/shitu_rec/config.py +141 -0
  898. paddlex/repo_apis/PaddleClas_api/shitu_rec/model.py +23 -0
  899. paddlex/repo_apis/PaddleClas_api/shitu_rec/register.py +68 -0
  900. paddlex/repo_apis/PaddleClas_api/shitu_rec/runner.py +55 -0
  901. paddlex/repo_apis/PaddleDetection_api/__init__.py +17 -0
  902. paddlex/repo_apis/PaddleDetection_api/config_helper.py +280 -0
  903. paddlex/repo_apis/PaddleDetection_api/instance_seg/__init__.py +18 -0
  904. paddlex/repo_apis/PaddleDetection_api/instance_seg/config.py +458 -0
  905. paddlex/repo_apis/PaddleDetection_api/instance_seg/model.py +403 -0
  906. paddlex/repo_apis/PaddleDetection_api/instance_seg/register.py +263 -0
  907. paddlex/repo_apis/PaddleDetection_api/instance_seg/runner.py +226 -0
  908. paddlex/repo_apis/PaddleDetection_api/object_det/__init__.py +19 -0
  909. paddlex/repo_apis/PaddleDetection_api/object_det/config.py +539 -0
  910. paddlex/repo_apis/PaddleDetection_api/object_det/model.py +430 -0
  911. paddlex/repo_apis/PaddleDetection_api/object_det/official_categories.py +220 -0
  912. paddlex/repo_apis/PaddleDetection_api/object_det/register.py +1106 -0
  913. paddlex/repo_apis/PaddleDetection_api/object_det/runner.py +226 -0
  914. paddlex/repo_apis/PaddleNLP_api/__init__.py +13 -0
  915. paddlex/repo_apis/PaddleOCR_api/__init__.py +21 -0
  916. paddlex/repo_apis/PaddleOCR_api/config_utils.py +53 -0
  917. paddlex/repo_apis/PaddleOCR_api/formula_rec/__init__.py +16 -0
  918. paddlex/repo_apis/PaddleOCR_api/formula_rec/config.py +570 -0
  919. paddlex/repo_apis/PaddleOCR_api/formula_rec/model.py +402 -0
  920. paddlex/repo_apis/PaddleOCR_api/formula_rec/register.py +73 -0
  921. paddlex/repo_apis/PaddleOCR_api/formula_rec/runner.py +240 -0
  922. paddlex/repo_apis/PaddleOCR_api/table_rec/__init__.py +16 -0
  923. paddlex/repo_apis/PaddleOCR_api/table_rec/config.py +64 -0
  924. paddlex/repo_apis/PaddleOCR_api/table_rec/model.py +126 -0
  925. paddlex/repo_apis/PaddleOCR_api/table_rec/register.py +71 -0
  926. paddlex/repo_apis/PaddleOCR_api/table_rec/runner.py +51 -0
  927. paddlex/repo_apis/PaddleOCR_api/text_det/__init__.py +16 -0
  928. paddlex/repo_apis/PaddleOCR_api/text_det/config.py +62 -0
  929. paddlex/repo_apis/PaddleOCR_api/text_det/model.py +72 -0
  930. paddlex/repo_apis/PaddleOCR_api/text_det/register.py +90 -0
  931. paddlex/repo_apis/PaddleOCR_api/text_det/runner.py +53 -0
  932. paddlex/repo_apis/PaddleOCR_api/text_rec/__init__.py +16 -0
  933. paddlex/repo_apis/PaddleOCR_api/text_rec/config.py +563 -0
  934. paddlex/repo_apis/PaddleOCR_api/text_rec/model.py +402 -0
  935. paddlex/repo_apis/PaddleOCR_api/text_rec/register.py +199 -0
  936. paddlex/repo_apis/PaddleOCR_api/text_rec/runner.py +240 -0
  937. paddlex/repo_apis/PaddleSeg_api/__init__.py +16 -0
  938. paddlex/repo_apis/PaddleSeg_api/base_seg_config.py +134 -0
  939. paddlex/repo_apis/PaddleSeg_api/seg/__init__.py +16 -0
  940. paddlex/repo_apis/PaddleSeg_api/seg/config.py +186 -0
  941. paddlex/repo_apis/PaddleSeg_api/seg/model.py +491 -0
  942. paddlex/repo_apis/PaddleSeg_api/seg/register.py +273 -0
  943. paddlex/repo_apis/PaddleSeg_api/seg/runner.py +262 -0
  944. paddlex/repo_apis/PaddleTS_api/__init__.py +19 -0
  945. paddlex/repo_apis/PaddleTS_api/ts_ad/__init__.py +16 -0
  946. paddlex/repo_apis/PaddleTS_api/ts_ad/config.py +89 -0
  947. paddlex/repo_apis/PaddleTS_api/ts_ad/register.py +146 -0
  948. paddlex/repo_apis/PaddleTS_api/ts_ad/runner.py +158 -0
  949. paddlex/repo_apis/PaddleTS_api/ts_base/__init__.py +13 -0
  950. paddlex/repo_apis/PaddleTS_api/ts_base/config.py +246 -0
  951. paddlex/repo_apis/PaddleTS_api/ts_base/model.py +276 -0
  952. paddlex/repo_apis/PaddleTS_api/ts_base/runner.py +158 -0
  953. paddlex/repo_apis/PaddleTS_api/ts_cls/__init__.py +16 -0
  954. paddlex/repo_apis/PaddleTS_api/ts_cls/config.py +73 -0
  955. paddlex/repo_apis/PaddleTS_api/ts_cls/register.py +59 -0
  956. paddlex/repo_apis/PaddleTS_api/ts_cls/runner.py +158 -0
  957. paddlex/repo_apis/PaddleTS_api/ts_fc/__init__.py +16 -0
  958. paddlex/repo_apis/PaddleTS_api/ts_fc/config.py +137 -0
  959. paddlex/repo_apis/PaddleTS_api/ts_fc/register.py +186 -0
  960. paddlex/repo_apis/PaddleVideo_api/__init__.py +17 -0
  961. paddlex/repo_apis/PaddleVideo_api/config_utils.py +51 -0
  962. paddlex/repo_apis/PaddleVideo_api/video_cls/__init__.py +19 -0
  963. paddlex/repo_apis/PaddleVideo_api/video_cls/config.py +547 -0
  964. paddlex/repo_apis/PaddleVideo_api/video_cls/model.py +346 -0
  965. paddlex/repo_apis/PaddleVideo_api/video_cls/register.py +71 -0
  966. paddlex/repo_apis/PaddleVideo_api/video_cls/runner.py +205 -0
  967. paddlex/repo_apis/PaddleVideo_api/video_det/__init__.py +19 -0
  968. paddlex/repo_apis/PaddleVideo_api/video_det/config.py +548 -0
  969. paddlex/repo_apis/PaddleVideo_api/video_det/model.py +298 -0
  970. paddlex/repo_apis/PaddleVideo_api/video_det/register.py +45 -0
  971. paddlex/repo_apis/PaddleVideo_api/video_det/runner.py +200 -0
  972. paddlex/repo_apis/__init__.py +13 -0
  973. paddlex/repo_apis/base/__init__.py +23 -0
  974. paddlex/repo_apis/base/config.py +238 -0
  975. paddlex/repo_apis/base/model.py +571 -0
  976. paddlex/repo_apis/base/register.py +135 -0
  977. paddlex/repo_apis/base/runner.py +391 -0
  978. paddlex/repo_apis/base/utils/__init__.py +13 -0
  979. paddlex/repo_apis/base/utils/arg.py +64 -0
  980. paddlex/repo_apis/base/utils/subprocess.py +107 -0
  981. paddlex/repo_manager/__init__.py +24 -0
  982. paddlex/repo_manager/core.py +271 -0
  983. paddlex/repo_manager/meta.py +170 -0
  984. paddlex/repo_manager/repo.py +415 -0
  985. paddlex/repo_manager/requirements.txt +21 -0
  986. paddlex/repo_manager/utils.py +359 -0
  987. paddlex/serving_requirements.txt +9 -0
  988. paddlex/utils/__init__.py +1 -12
  989. paddlex/utils/cache.py +148 -0
  990. paddlex/utils/config.py +215 -0
  991. paddlex/utils/custom_device_whitelist.py +457 -0
  992. paddlex/utils/device.py +151 -0
  993. paddlex/utils/download.py +168 -182
  994. paddlex/utils/env.py +11 -50
  995. paddlex/utils/errors/__init__.py +17 -0
  996. paddlex/utils/errors/dataset_checker.py +78 -0
  997. paddlex/utils/errors/others.py +152 -0
  998. paddlex/utils/file_interface.py +212 -0
  999. paddlex/utils/flags.py +65 -0
  1000. paddlex/utils/fonts/__init__.py +67 -0
  1001. paddlex/utils/func_register.py +41 -0
  1002. paddlex/utils/interactive_get_pipeline.py +55 -0
  1003. paddlex/utils/lazy_loader.py +68 -0
  1004. paddlex/utils/logging.py +131 -33
  1005. paddlex/utils/misc.py +201 -0
  1006. paddlex/utils/pipeline_arguments.py +711 -0
  1007. paddlex/utils/result_saver.py +59 -0
  1008. paddlex/utils/subclass_register.py +101 -0
  1009. paddlex/version.py +54 -0
  1010. paddlex-3.0.0rc0.dist-info/LICENSE +169 -0
  1011. paddlex-3.0.0rc0.dist-info/METADATA +1035 -0
  1012. paddlex-3.0.0rc0.dist-info/RECORD +1015 -0
  1013. paddlex-3.0.0rc0.dist-info/WHEEL +5 -0
  1014. paddlex-3.0.0rc0.dist-info/entry_points.txt +2 -0
  1015. paddlex-3.0.0rc0.dist-info/top_level.txt +1 -0
  1016. PaddleClas/__init__.py +0 -16
  1017. PaddleClas/deploy/__init__.py +0 -1
  1018. PaddleClas/deploy/paddleserving/__init__.py +0 -0
  1019. PaddleClas/deploy/paddleserving/classification_web_service.py +0 -74
  1020. PaddleClas/deploy/paddleserving/cpu_utilization.py +0 -4
  1021. PaddleClas/deploy/paddleserving/pipeline_http_client.py +0 -20
  1022. PaddleClas/deploy/paddleserving/pipeline_rpc_client.py +0 -33
  1023. PaddleClas/deploy/paddleserving/recognition/__init__.py +0 -0
  1024. PaddleClas/deploy/paddleserving/recognition/pipeline_http_client.py +0 -21
  1025. PaddleClas/deploy/paddleserving/recognition/pipeline_rpc_client.py +0 -34
  1026. PaddleClas/deploy/paddleserving/recognition/recognition_web_service.py +0 -209
  1027. PaddleClas/deploy/python/__init__.py +0 -0
  1028. PaddleClas/deploy/python/build_gallery.py +0 -214
  1029. PaddleClas/deploy/python/det_preprocess.py +0 -205
  1030. PaddleClas/deploy/python/postprocess.py +0 -161
  1031. PaddleClas/deploy/python/predict_cls.py +0 -142
  1032. PaddleClas/deploy/python/predict_det.py +0 -158
  1033. PaddleClas/deploy/python/predict_rec.py +0 -138
  1034. PaddleClas/deploy/python/predict_system.py +0 -144
  1035. PaddleClas/deploy/python/preprocess.py +0 -337
  1036. PaddleClas/deploy/utils/__init__.py +0 -5
  1037. PaddleClas/deploy/utils/config.py +0 -197
  1038. PaddleClas/deploy/utils/draw_bbox.py +0 -61
  1039. PaddleClas/deploy/utils/encode_decode.py +0 -31
  1040. PaddleClas/deploy/utils/get_image_list.py +0 -49
  1041. PaddleClas/deploy/utils/logger.py +0 -120
  1042. PaddleClas/deploy/utils/predictor.py +0 -71
  1043. PaddleClas/deploy/vector_search/__init__.py +0 -1
  1044. PaddleClas/deploy/vector_search/interface.py +0 -272
  1045. PaddleClas/deploy/vector_search/test.py +0 -34
  1046. PaddleClas/hubconf.py +0 -788
  1047. PaddleClas/paddleclas.py +0 -552
  1048. PaddleClas/ppcls/__init__.py +0 -20
  1049. PaddleClas/ppcls/arch/__init__.py +0 -127
  1050. PaddleClas/ppcls/arch/backbone/__init__.py +0 -80
  1051. PaddleClas/ppcls/arch/backbone/base/__init__.py +0 -0
  1052. PaddleClas/ppcls/arch/backbone/base/theseus_layer.py +0 -126
  1053. PaddleClas/ppcls/arch/backbone/legendary_models/__init__.py +0 -6
  1054. PaddleClas/ppcls/arch/backbone/legendary_models/esnet.py +0 -355
  1055. PaddleClas/ppcls/arch/backbone/legendary_models/hrnet.py +0 -744
  1056. PaddleClas/ppcls/arch/backbone/legendary_models/inception_v3.py +0 -539
  1057. PaddleClas/ppcls/arch/backbone/legendary_models/mobilenet_v1.py +0 -234
  1058. PaddleClas/ppcls/arch/backbone/legendary_models/mobilenet_v3.py +0 -561
  1059. PaddleClas/ppcls/arch/backbone/legendary_models/pp_lcnet.py +0 -399
  1060. PaddleClas/ppcls/arch/backbone/legendary_models/resnet.py +0 -534
  1061. PaddleClas/ppcls/arch/backbone/legendary_models/vgg.py +0 -231
  1062. PaddleClas/ppcls/arch/backbone/model_zoo/__init__.py +0 -0
  1063. PaddleClas/ppcls/arch/backbone/model_zoo/alexnet.py +0 -168
  1064. PaddleClas/ppcls/arch/backbone/model_zoo/cspnet.py +0 -376
  1065. PaddleClas/ppcls/arch/backbone/model_zoo/darknet.py +0 -197
  1066. PaddleClas/ppcls/arch/backbone/model_zoo/densenet.py +0 -344
  1067. PaddleClas/ppcls/arch/backbone/model_zoo/distilled_vision_transformer.py +0 -272
  1068. PaddleClas/ppcls/arch/backbone/model_zoo/dla.py +0 -528
  1069. PaddleClas/ppcls/arch/backbone/model_zoo/dpn.py +0 -451
  1070. PaddleClas/ppcls/arch/backbone/model_zoo/efficientnet.py +0 -976
  1071. PaddleClas/ppcls/arch/backbone/model_zoo/ghostnet.py +0 -363
  1072. PaddleClas/ppcls/arch/backbone/model_zoo/googlenet.py +0 -229
  1073. PaddleClas/ppcls/arch/backbone/model_zoo/gvt.py +0 -693
  1074. PaddleClas/ppcls/arch/backbone/model_zoo/hardnet.py +0 -293
  1075. PaddleClas/ppcls/arch/backbone/model_zoo/inception_v4.py +0 -477
  1076. PaddleClas/ppcls/arch/backbone/model_zoo/levit.py +0 -589
  1077. PaddleClas/ppcls/arch/backbone/model_zoo/mixnet.py +0 -815
  1078. PaddleClas/ppcls/arch/backbone/model_zoo/mobilenet_v2.py +0 -287
  1079. PaddleClas/ppcls/arch/backbone/model_zoo/rednet.py +0 -203
  1080. PaddleClas/ppcls/arch/backbone/model_zoo/regnet.py +0 -431
  1081. PaddleClas/ppcls/arch/backbone/model_zoo/repvgg.py +0 -422
  1082. PaddleClas/ppcls/arch/backbone/model_zoo/res2net.py +0 -264
  1083. PaddleClas/ppcls/arch/backbone/model_zoo/res2net_vd.py +0 -305
  1084. PaddleClas/ppcls/arch/backbone/model_zoo/resnest.py +0 -740
  1085. PaddleClas/ppcls/arch/backbone/model_zoo/resnet_vc.py +0 -309
  1086. PaddleClas/ppcls/arch/backbone/model_zoo/resnext.py +0 -298
  1087. PaddleClas/ppcls/arch/backbone/model_zoo/resnext101_wsl.py +0 -490
  1088. PaddleClas/ppcls/arch/backbone/model_zoo/resnext_vd.py +0 -317
  1089. PaddleClas/ppcls/arch/backbone/model_zoo/rexnet.py +0 -281
  1090. PaddleClas/ppcls/arch/backbone/model_zoo/se_resnet_vd.py +0 -390
  1091. PaddleClas/ppcls/arch/backbone/model_zoo/se_resnext.py +0 -364
  1092. PaddleClas/ppcls/arch/backbone/model_zoo/se_resnext_vd.py +0 -309
  1093. PaddleClas/ppcls/arch/backbone/model_zoo/shufflenet_v2.py +0 -362
  1094. PaddleClas/ppcls/arch/backbone/model_zoo/squeezenet.py +0 -194
  1095. PaddleClas/ppcls/arch/backbone/model_zoo/swin_transformer.py +0 -857
  1096. PaddleClas/ppcls/arch/backbone/model_zoo/tnt.py +0 -385
  1097. PaddleClas/ppcls/arch/backbone/model_zoo/vision_transformer.py +0 -495
  1098. PaddleClas/ppcls/arch/backbone/model_zoo/xception.py +0 -377
  1099. PaddleClas/ppcls/arch/backbone/model_zoo/xception_deeplab.py +0 -421
  1100. PaddleClas/ppcls/arch/backbone/variant_models/__init__.py +0 -3
  1101. PaddleClas/ppcls/arch/backbone/variant_models/pp_lcnet_variant.py +0 -29
  1102. PaddleClas/ppcls/arch/backbone/variant_models/resnet_variant.py +0 -23
  1103. PaddleClas/ppcls/arch/backbone/variant_models/vgg_variant.py +0 -28
  1104. PaddleClas/ppcls/arch/gears/__init__.py +0 -32
  1105. PaddleClas/ppcls/arch/gears/arcmargin.py +0 -72
  1106. PaddleClas/ppcls/arch/gears/circlemargin.py +0 -59
  1107. PaddleClas/ppcls/arch/gears/cosmargin.py +0 -55
  1108. PaddleClas/ppcls/arch/gears/fc.py +0 -35
  1109. PaddleClas/ppcls/arch/gears/identity_head.py +0 -9
  1110. PaddleClas/ppcls/arch/gears/vehicle_neck.py +0 -52
  1111. PaddleClas/ppcls/arch/utils.py +0 -53
  1112. PaddleClas/ppcls/data/__init__.py +0 -144
  1113. PaddleClas/ppcls/data/dataloader/DistributedRandomIdentitySampler.py +0 -90
  1114. PaddleClas/ppcls/data/dataloader/__init__.py +0 -9
  1115. PaddleClas/ppcls/data/dataloader/common_dataset.py +0 -84
  1116. PaddleClas/ppcls/data/dataloader/dali.py +0 -319
  1117. PaddleClas/ppcls/data/dataloader/icartoon_dataset.py +0 -36
  1118. PaddleClas/ppcls/data/dataloader/imagenet_dataset.py +0 -38
  1119. PaddleClas/ppcls/data/dataloader/logo_dataset.py +0 -46
  1120. PaddleClas/ppcls/data/dataloader/mix_dataset.py +0 -49
  1121. PaddleClas/ppcls/data/dataloader/mix_sampler.py +0 -79
  1122. PaddleClas/ppcls/data/dataloader/multilabel_dataset.py +0 -59
  1123. PaddleClas/ppcls/data/dataloader/pk_sampler.py +0 -105
  1124. PaddleClas/ppcls/data/dataloader/vehicle_dataset.py +0 -138
  1125. PaddleClas/ppcls/data/postprocess/__init__.py +0 -41
  1126. PaddleClas/ppcls/data/postprocess/topk.py +0 -85
  1127. PaddleClas/ppcls/data/preprocess/__init__.py +0 -100
  1128. PaddleClas/ppcls/data/preprocess/batch_ops/__init__.py +0 -1
  1129. PaddleClas/ppcls/data/preprocess/batch_ops/batch_operators.py +0 -231
  1130. PaddleClas/ppcls/data/preprocess/ops/__init__.py +0 -1
  1131. PaddleClas/ppcls/data/preprocess/ops/autoaugment.py +0 -264
  1132. PaddleClas/ppcls/data/preprocess/ops/cutout.py +0 -41
  1133. PaddleClas/ppcls/data/preprocess/ops/fmix.py +0 -217
  1134. PaddleClas/ppcls/data/preprocess/ops/functional.py +0 -138
  1135. PaddleClas/ppcls/data/preprocess/ops/grid.py +0 -89
  1136. PaddleClas/ppcls/data/preprocess/ops/hide_and_seek.py +0 -44
  1137. PaddleClas/ppcls/data/preprocess/ops/operators.py +0 -384
  1138. PaddleClas/ppcls/data/preprocess/ops/randaugment.py +0 -106
  1139. PaddleClas/ppcls/data/preprocess/ops/random_erasing.py +0 -90
  1140. PaddleClas/ppcls/data/preprocess/ops/timm_autoaugment.py +0 -877
  1141. PaddleClas/ppcls/data/utils/__init__.py +0 -13
  1142. PaddleClas/ppcls/data/utils/get_image_list.py +0 -49
  1143. PaddleClas/ppcls/engine/__init__.py +0 -0
  1144. PaddleClas/ppcls/engine/engine.py +0 -436
  1145. PaddleClas/ppcls/engine/evaluation/__init__.py +0 -16
  1146. PaddleClas/ppcls/engine/evaluation/classification.py +0 -143
  1147. PaddleClas/ppcls/engine/evaluation/retrieval.py +0 -169
  1148. PaddleClas/ppcls/engine/slim/__init__.py +0 -16
  1149. PaddleClas/ppcls/engine/slim/prune.py +0 -66
  1150. PaddleClas/ppcls/engine/slim/quant.py +0 -55
  1151. PaddleClas/ppcls/engine/train/__init__.py +0 -14
  1152. PaddleClas/ppcls/engine/train/train.py +0 -79
  1153. PaddleClas/ppcls/engine/train/utils.py +0 -72
  1154. PaddleClas/ppcls/loss/__init__.py +0 -65
  1155. PaddleClas/ppcls/loss/celoss.py +0 -67
  1156. PaddleClas/ppcls/loss/centerloss.py +0 -54
  1157. PaddleClas/ppcls/loss/comfunc.py +0 -45
  1158. PaddleClas/ppcls/loss/deephashloss.py +0 -92
  1159. PaddleClas/ppcls/loss/distanceloss.py +0 -43
  1160. PaddleClas/ppcls/loss/distillationloss.py +0 -141
  1161. PaddleClas/ppcls/loss/dmlloss.py +0 -46
  1162. PaddleClas/ppcls/loss/emlloss.py +0 -97
  1163. PaddleClas/ppcls/loss/googlenetloss.py +0 -41
  1164. PaddleClas/ppcls/loss/msmloss.py +0 -78
  1165. PaddleClas/ppcls/loss/multilabelloss.py +0 -43
  1166. PaddleClas/ppcls/loss/npairsloss.py +0 -38
  1167. PaddleClas/ppcls/loss/pairwisecosface.py +0 -55
  1168. PaddleClas/ppcls/loss/supconloss.py +0 -108
  1169. PaddleClas/ppcls/loss/trihardloss.py +0 -82
  1170. PaddleClas/ppcls/loss/triplet.py +0 -137
  1171. PaddleClas/ppcls/metric/__init__.py +0 -51
  1172. PaddleClas/ppcls/metric/metrics.py +0 -308
  1173. PaddleClas/ppcls/optimizer/__init__.py +0 -72
  1174. PaddleClas/ppcls/optimizer/learning_rate.py +0 -326
  1175. PaddleClas/ppcls/optimizer/optimizer.py +0 -207
  1176. PaddleClas/ppcls/utils/__init__.py +0 -27
  1177. PaddleClas/ppcls/utils/check.py +0 -151
  1178. PaddleClas/ppcls/utils/config.py +0 -210
  1179. PaddleClas/ppcls/utils/download.py +0 -319
  1180. PaddleClas/ppcls/utils/ema.py +0 -63
  1181. PaddleClas/ppcls/utils/logger.py +0 -137
  1182. PaddleClas/ppcls/utils/metrics.py +0 -107
  1183. PaddleClas/ppcls/utils/misc.py +0 -63
  1184. PaddleClas/ppcls/utils/model_zoo.py +0 -213
  1185. PaddleClas/ppcls/utils/profiler.py +0 -111
  1186. PaddleClas/ppcls/utils/save_load.py +0 -136
  1187. PaddleClas/setup.py +0 -58
  1188. PaddleClas/tools/__init__.py +0 -15
  1189. PaddleClas/tools/eval.py +0 -31
  1190. PaddleClas/tools/export_model.py +0 -34
  1191. PaddleClas/tools/infer.py +0 -31
  1192. PaddleClas/tools/train.py +0 -32
  1193. paddlex/cls.py +0 -82
  1194. paddlex/command.py +0 -215
  1195. paddlex/cv/__init__.py +0 -17
  1196. paddlex/cv/datasets/__init__.py +0 -18
  1197. paddlex/cv/datasets/coco.py +0 -208
  1198. paddlex/cv/datasets/imagenet.py +0 -88
  1199. paddlex/cv/datasets/seg_dataset.py +0 -91
  1200. paddlex/cv/datasets/voc.py +0 -445
  1201. paddlex/cv/models/__init__.py +0 -18
  1202. paddlex/cv/models/base.py +0 -631
  1203. paddlex/cv/models/classifier.py +0 -989
  1204. paddlex/cv/models/detector.py +0 -2292
  1205. paddlex/cv/models/load_model.py +0 -148
  1206. paddlex/cv/models/segmenter.py +0 -768
  1207. paddlex/cv/models/slim/__init__.py +0 -13
  1208. paddlex/cv/models/slim/prune.py +0 -55
  1209. paddlex/cv/models/utils/__init__.py +0 -13
  1210. paddlex/cv/models/utils/det_metrics/__init__.py +0 -15
  1211. paddlex/cv/models/utils/det_metrics/coco_utils.py +0 -476
  1212. paddlex/cv/models/utils/det_metrics/metrics.py +0 -220
  1213. paddlex/cv/models/utils/infer_nets.py +0 -45
  1214. paddlex/cv/models/utils/seg_metrics.py +0 -62
  1215. paddlex/cv/models/utils/visualize.py +0 -399
  1216. paddlex/cv/transforms/__init__.py +0 -46
  1217. paddlex/cv/transforms/batch_operators.py +0 -286
  1218. paddlex/cv/transforms/box_utils.py +0 -41
  1219. paddlex/cv/transforms/functions.py +0 -193
  1220. paddlex/cv/transforms/operators.py +0 -1402
  1221. paddlex/deploy.py +0 -268
  1222. paddlex/det.py +0 -49
  1223. paddlex/paddleseg/__init__.py +0 -17
  1224. paddlex/paddleseg/core/__init__.py +0 -20
  1225. paddlex/paddleseg/core/infer.py +0 -289
  1226. paddlex/paddleseg/core/predict.py +0 -145
  1227. paddlex/paddleseg/core/train.py +0 -258
  1228. paddlex/paddleseg/core/val.py +0 -172
  1229. paddlex/paddleseg/cvlibs/__init__.py +0 -17
  1230. paddlex/paddleseg/cvlibs/callbacks.py +0 -279
  1231. paddlex/paddleseg/cvlibs/config.py +0 -359
  1232. paddlex/paddleseg/cvlibs/manager.py +0 -142
  1233. paddlex/paddleseg/cvlibs/param_init.py +0 -91
  1234. paddlex/paddleseg/datasets/__init__.py +0 -21
  1235. paddlex/paddleseg/datasets/ade.py +0 -112
  1236. paddlex/paddleseg/datasets/cityscapes.py +0 -86
  1237. paddlex/paddleseg/datasets/cocostuff.py +0 -79
  1238. paddlex/paddleseg/datasets/dataset.py +0 -164
  1239. paddlex/paddleseg/datasets/mini_deep_globe_road_extraction.py +0 -95
  1240. paddlex/paddleseg/datasets/optic_disc_seg.py +0 -97
  1241. paddlex/paddleseg/datasets/pascal_context.py +0 -80
  1242. paddlex/paddleseg/datasets/voc.py +0 -113
  1243. paddlex/paddleseg/models/__init__.py +0 -39
  1244. paddlex/paddleseg/models/ann.py +0 -436
  1245. paddlex/paddleseg/models/attention_unet.py +0 -189
  1246. paddlex/paddleseg/models/backbones/__init__.py +0 -18
  1247. paddlex/paddleseg/models/backbones/hrnet.py +0 -815
  1248. paddlex/paddleseg/models/backbones/mobilenetv3.py +0 -365
  1249. paddlex/paddleseg/models/backbones/resnet_vd.py +0 -364
  1250. paddlex/paddleseg/models/backbones/xception_deeplab.py +0 -415
  1251. paddlex/paddleseg/models/bisenet.py +0 -311
  1252. paddlex/paddleseg/models/danet.py +0 -220
  1253. paddlex/paddleseg/models/decoupled_segnet.py +0 -233
  1254. paddlex/paddleseg/models/deeplab.py +0 -258
  1255. paddlex/paddleseg/models/dnlnet.py +0 -231
  1256. paddlex/paddleseg/models/emanet.py +0 -219
  1257. paddlex/paddleseg/models/fast_scnn.py +0 -318
  1258. paddlex/paddleseg/models/fcn.py +0 -135
  1259. paddlex/paddleseg/models/gcnet.py +0 -223
  1260. paddlex/paddleseg/models/gscnn.py +0 -357
  1261. paddlex/paddleseg/models/hardnet.py +0 -309
  1262. paddlex/paddleseg/models/isanet.py +0 -202
  1263. paddlex/paddleseg/models/layers/__init__.py +0 -19
  1264. paddlex/paddleseg/models/layers/activation.py +0 -73
  1265. paddlex/paddleseg/models/layers/attention.py +0 -146
  1266. paddlex/paddleseg/models/layers/layer_libs.py +0 -168
  1267. paddlex/paddleseg/models/layers/nonlocal2d.py +0 -155
  1268. paddlex/paddleseg/models/layers/pyramid_pool.py +0 -182
  1269. paddlex/paddleseg/models/losses/__init__.py +0 -27
  1270. paddlex/paddleseg/models/losses/binary_cross_entropy_loss.py +0 -174
  1271. paddlex/paddleseg/models/losses/bootstrapped_cross_entropy.py +0 -73
  1272. paddlex/paddleseg/models/losses/cross_entropy_loss.py +0 -94
  1273. paddlex/paddleseg/models/losses/decoupledsegnet_relax_boundary_loss.py +0 -129
  1274. paddlex/paddleseg/models/losses/dice_loss.py +0 -61
  1275. paddlex/paddleseg/models/losses/edge_attention_loss.py +0 -78
  1276. paddlex/paddleseg/models/losses/gscnn_dual_task_loss.py +0 -141
  1277. paddlex/paddleseg/models/losses/l1_loss.py +0 -76
  1278. paddlex/paddleseg/models/losses/lovasz_loss.py +0 -222
  1279. paddlex/paddleseg/models/losses/mean_square_error_loss.py +0 -65
  1280. paddlex/paddleseg/models/losses/mixed_loss.py +0 -58
  1281. paddlex/paddleseg/models/losses/ohem_cross_entropy_loss.py +0 -99
  1282. paddlex/paddleseg/models/losses/ohem_edge_attention_loss.py +0 -114
  1283. paddlex/paddleseg/models/ocrnet.py +0 -248
  1284. paddlex/paddleseg/models/pspnet.py +0 -147
  1285. paddlex/paddleseg/models/sfnet.py +0 -236
  1286. paddlex/paddleseg/models/shufflenet_slim.py +0 -268
  1287. paddlex/paddleseg/models/u2net.py +0 -574
  1288. paddlex/paddleseg/models/unet.py +0 -155
  1289. paddlex/paddleseg/models/unet_3plus.py +0 -316
  1290. paddlex/paddleseg/models/unet_plusplus.py +0 -237
  1291. paddlex/paddleseg/transforms/__init__.py +0 -16
  1292. paddlex/paddleseg/transforms/functional.py +0 -161
  1293. paddlex/paddleseg/transforms/transforms.py +0 -937
  1294. paddlex/paddleseg/utils/__init__.py +0 -22
  1295. paddlex/paddleseg/utils/config_check.py +0 -60
  1296. paddlex/paddleseg/utils/download.py +0 -163
  1297. paddlex/paddleseg/utils/env/__init__.py +0 -16
  1298. paddlex/paddleseg/utils/env/seg_env.py +0 -56
  1299. paddlex/paddleseg/utils/env/sys_env.py +0 -122
  1300. paddlex/paddleseg/utils/logger.py +0 -48
  1301. paddlex/paddleseg/utils/metrics.py +0 -146
  1302. paddlex/paddleseg/utils/progbar.py +0 -212
  1303. paddlex/paddleseg/utils/timer.py +0 -53
  1304. paddlex/paddleseg/utils/utils.py +0 -120
  1305. paddlex/paddleseg/utils/visualize.py +0 -90
  1306. paddlex/ppcls/__init__.py +0 -20
  1307. paddlex/ppcls/arch/__init__.py +0 -127
  1308. paddlex/ppcls/arch/backbone/__init__.py +0 -80
  1309. paddlex/ppcls/arch/backbone/base/__init__.py +0 -0
  1310. paddlex/ppcls/arch/backbone/base/theseus_layer.py +0 -130
  1311. paddlex/ppcls/arch/backbone/legendary_models/__init__.py +0 -6
  1312. paddlex/ppcls/arch/backbone/legendary_models/esnet.py +0 -355
  1313. paddlex/ppcls/arch/backbone/legendary_models/hrnet.py +0 -748
  1314. paddlex/ppcls/arch/backbone/legendary_models/inception_v3.py +0 -539
  1315. paddlex/ppcls/arch/backbone/legendary_models/mobilenet_v1.py +0 -234
  1316. paddlex/ppcls/arch/backbone/legendary_models/mobilenet_v3.py +0 -561
  1317. paddlex/ppcls/arch/backbone/legendary_models/pp_lcnet.py +0 -399
  1318. paddlex/ppcls/arch/backbone/legendary_models/resnet.py +0 -534
  1319. paddlex/ppcls/arch/backbone/legendary_models/vgg.py +0 -235
  1320. paddlex/ppcls/arch/backbone/model_zoo/__init__.py +0 -0
  1321. paddlex/ppcls/arch/backbone/model_zoo/alexnet.py +0 -168
  1322. paddlex/ppcls/arch/backbone/model_zoo/cspnet.py +0 -376
  1323. paddlex/ppcls/arch/backbone/model_zoo/darknet.py +0 -197
  1324. paddlex/ppcls/arch/backbone/model_zoo/densenet.py +0 -344
  1325. paddlex/ppcls/arch/backbone/model_zoo/distilled_vision_transformer.py +0 -272
  1326. paddlex/ppcls/arch/backbone/model_zoo/dla.py +0 -528
  1327. paddlex/ppcls/arch/backbone/model_zoo/dpn.py +0 -451
  1328. paddlex/ppcls/arch/backbone/model_zoo/efficientnet.py +0 -976
  1329. paddlex/ppcls/arch/backbone/model_zoo/ghostnet.py +0 -363
  1330. paddlex/ppcls/arch/backbone/model_zoo/googlenet.py +0 -229
  1331. paddlex/ppcls/arch/backbone/model_zoo/gvt.py +0 -693
  1332. paddlex/ppcls/arch/backbone/model_zoo/hardnet.py +0 -293
  1333. paddlex/ppcls/arch/backbone/model_zoo/inception_v4.py +0 -477
  1334. paddlex/ppcls/arch/backbone/model_zoo/levit.py +0 -589
  1335. paddlex/ppcls/arch/backbone/model_zoo/mixnet.py +0 -815
  1336. paddlex/ppcls/arch/backbone/model_zoo/mobilenet_v2.py +0 -287
  1337. paddlex/ppcls/arch/backbone/model_zoo/rednet.py +0 -203
  1338. paddlex/ppcls/arch/backbone/model_zoo/regnet.py +0 -431
  1339. paddlex/ppcls/arch/backbone/model_zoo/repvgg.py +0 -422
  1340. paddlex/ppcls/arch/backbone/model_zoo/res2net.py +0 -264
  1341. paddlex/ppcls/arch/backbone/model_zoo/res2net_vd.py +0 -305
  1342. paddlex/ppcls/arch/backbone/model_zoo/resnest.py +0 -740
  1343. paddlex/ppcls/arch/backbone/model_zoo/resnet_vc.py +0 -309
  1344. paddlex/ppcls/arch/backbone/model_zoo/resnext.py +0 -298
  1345. paddlex/ppcls/arch/backbone/model_zoo/resnext101_wsl.py +0 -490
  1346. paddlex/ppcls/arch/backbone/model_zoo/resnext_vd.py +0 -317
  1347. paddlex/ppcls/arch/backbone/model_zoo/rexnet.py +0 -281
  1348. paddlex/ppcls/arch/backbone/model_zoo/se_resnet_vd.py +0 -390
  1349. paddlex/ppcls/arch/backbone/model_zoo/se_resnext.py +0 -364
  1350. paddlex/ppcls/arch/backbone/model_zoo/se_resnext_vd.py +0 -309
  1351. paddlex/ppcls/arch/backbone/model_zoo/shufflenet_v2.py +0 -362
  1352. paddlex/ppcls/arch/backbone/model_zoo/squeezenet.py +0 -194
  1353. paddlex/ppcls/arch/backbone/model_zoo/swin_transformer.py +0 -857
  1354. paddlex/ppcls/arch/backbone/model_zoo/tnt.py +0 -385
  1355. paddlex/ppcls/arch/backbone/model_zoo/vision_transformer.py +0 -495
  1356. paddlex/ppcls/arch/backbone/model_zoo/xception.py +0 -377
  1357. paddlex/ppcls/arch/backbone/model_zoo/xception_deeplab.py +0 -421
  1358. paddlex/ppcls/arch/backbone/variant_models/__init__.py +0 -3
  1359. paddlex/ppcls/arch/backbone/variant_models/pp_lcnet_variant.py +0 -29
  1360. paddlex/ppcls/arch/backbone/variant_models/resnet_variant.py +0 -23
  1361. paddlex/ppcls/arch/backbone/variant_models/vgg_variant.py +0 -28
  1362. paddlex/ppcls/arch/gears/__init__.py +0 -32
  1363. paddlex/ppcls/arch/gears/arcmargin.py +0 -72
  1364. paddlex/ppcls/arch/gears/circlemargin.py +0 -59
  1365. paddlex/ppcls/arch/gears/cosmargin.py +0 -55
  1366. paddlex/ppcls/arch/gears/fc.py +0 -35
  1367. paddlex/ppcls/arch/gears/identity_head.py +0 -9
  1368. paddlex/ppcls/arch/gears/vehicle_neck.py +0 -52
  1369. paddlex/ppcls/arch/utils.py +0 -53
  1370. paddlex/ppcls/data/__init__.py +0 -144
  1371. paddlex/ppcls/data/dataloader/DistributedRandomIdentitySampler.py +0 -90
  1372. paddlex/ppcls/data/dataloader/__init__.py +0 -9
  1373. paddlex/ppcls/data/dataloader/common_dataset.py +0 -84
  1374. paddlex/ppcls/data/dataloader/dali.py +0 -319
  1375. paddlex/ppcls/data/dataloader/icartoon_dataset.py +0 -36
  1376. paddlex/ppcls/data/dataloader/imagenet_dataset.py +0 -38
  1377. paddlex/ppcls/data/dataloader/logo_dataset.py +0 -46
  1378. paddlex/ppcls/data/dataloader/mix_dataset.py +0 -49
  1379. paddlex/ppcls/data/dataloader/mix_sampler.py +0 -79
  1380. paddlex/ppcls/data/dataloader/multilabel_dataset.py +0 -59
  1381. paddlex/ppcls/data/dataloader/pk_sampler.py +0 -105
  1382. paddlex/ppcls/data/dataloader/vehicle_dataset.py +0 -138
  1383. paddlex/ppcls/data/postprocess/__init__.py +0 -41
  1384. paddlex/ppcls/data/postprocess/topk.py +0 -85
  1385. paddlex/ppcls/data/preprocess/__init__.py +0 -100
  1386. paddlex/ppcls/data/preprocess/batch_ops/__init__.py +0 -0
  1387. paddlex/ppcls/data/preprocess/batch_ops/batch_operators.py +0 -231
  1388. paddlex/ppcls/data/preprocess/ops/__init__.py +0 -0
  1389. paddlex/ppcls/data/preprocess/ops/autoaugment.py +0 -264
  1390. paddlex/ppcls/data/preprocess/ops/cutout.py +0 -41
  1391. paddlex/ppcls/data/preprocess/ops/fmix.py +0 -217
  1392. paddlex/ppcls/data/preprocess/ops/functional.py +0 -141
  1393. paddlex/ppcls/data/preprocess/ops/grid.py +0 -89
  1394. paddlex/ppcls/data/preprocess/ops/hide_and_seek.py +0 -44
  1395. paddlex/ppcls/data/preprocess/ops/operators.py +0 -384
  1396. paddlex/ppcls/data/preprocess/ops/randaugment.py +0 -106
  1397. paddlex/ppcls/data/preprocess/ops/random_erasing.py +0 -90
  1398. paddlex/ppcls/data/preprocess/ops/timm_autoaugment.py +0 -877
  1399. paddlex/ppcls/data/utils/__init__.py +0 -13
  1400. paddlex/ppcls/data/utils/get_image_list.py +0 -49
  1401. paddlex/ppcls/engine/__init__.py +0 -0
  1402. paddlex/ppcls/engine/engine.py +0 -436
  1403. paddlex/ppcls/engine/evaluation/__init__.py +0 -16
  1404. paddlex/ppcls/engine/evaluation/classification.py +0 -143
  1405. paddlex/ppcls/engine/evaluation/retrieval.py +0 -169
  1406. paddlex/ppcls/engine/slim/__init__.py +0 -16
  1407. paddlex/ppcls/engine/slim/prune.py +0 -66
  1408. paddlex/ppcls/engine/slim/quant.py +0 -55
  1409. paddlex/ppcls/engine/train/__init__.py +0 -14
  1410. paddlex/ppcls/engine/train/train.py +0 -79
  1411. paddlex/ppcls/engine/train/utils.py +0 -72
  1412. paddlex/ppcls/loss/__init__.py +0 -65
  1413. paddlex/ppcls/loss/celoss.py +0 -67
  1414. paddlex/ppcls/loss/centerloss.py +0 -54
  1415. paddlex/ppcls/loss/comfunc.py +0 -45
  1416. paddlex/ppcls/loss/deephashloss.py +0 -96
  1417. paddlex/ppcls/loss/distanceloss.py +0 -43
  1418. paddlex/ppcls/loss/distillationloss.py +0 -141
  1419. paddlex/ppcls/loss/dmlloss.py +0 -46
  1420. paddlex/ppcls/loss/emlloss.py +0 -97
  1421. paddlex/ppcls/loss/googlenetloss.py +0 -42
  1422. paddlex/ppcls/loss/msmloss.py +0 -78
  1423. paddlex/ppcls/loss/multilabelloss.py +0 -43
  1424. paddlex/ppcls/loss/npairsloss.py +0 -38
  1425. paddlex/ppcls/loss/pairwisecosface.py +0 -59
  1426. paddlex/ppcls/loss/supconloss.py +0 -108
  1427. paddlex/ppcls/loss/trihardloss.py +0 -82
  1428. paddlex/ppcls/loss/triplet.py +0 -137
  1429. paddlex/ppcls/metric/__init__.py +0 -51
  1430. paddlex/ppcls/metric/metrics.py +0 -308
  1431. paddlex/ppcls/optimizer/__init__.py +0 -72
  1432. paddlex/ppcls/optimizer/learning_rate.py +0 -326
  1433. paddlex/ppcls/optimizer/optimizer.py +0 -208
  1434. paddlex/ppcls/utils/__init__.py +0 -27
  1435. paddlex/ppcls/utils/check.py +0 -151
  1436. paddlex/ppcls/utils/config.py +0 -210
  1437. paddlex/ppcls/utils/download.py +0 -319
  1438. paddlex/ppcls/utils/ema.py +0 -63
  1439. paddlex/ppcls/utils/logger.py +0 -137
  1440. paddlex/ppcls/utils/metrics.py +0 -112
  1441. paddlex/ppcls/utils/misc.py +0 -63
  1442. paddlex/ppcls/utils/model_zoo.py +0 -213
  1443. paddlex/ppcls/utils/profiler.py +0 -111
  1444. paddlex/ppcls/utils/save_load.py +0 -136
  1445. paddlex/ppdet/__init__.py +0 -16
  1446. paddlex/ppdet/core/__init__.py +0 -15
  1447. paddlex/ppdet/core/config/__init__.py +0 -13
  1448. paddlex/ppdet/core/config/schema.py +0 -248
  1449. paddlex/ppdet/core/config/yaml_helpers.py +0 -118
  1450. paddlex/ppdet/core/workspace.py +0 -278
  1451. paddlex/ppdet/data/__init__.py +0 -21
  1452. paddlex/ppdet/data/crop_utils/__init__.py +0 -13
  1453. paddlex/ppdet/data/crop_utils/annotation_cropper.py +0 -585
  1454. paddlex/ppdet/data/crop_utils/chip_box_utils.py +0 -170
  1455. paddlex/ppdet/data/reader.py +0 -302
  1456. paddlex/ppdet/data/shm_utils.py +0 -67
  1457. paddlex/ppdet/data/source/__init__.py +0 -29
  1458. paddlex/ppdet/data/source/category.py +0 -904
  1459. paddlex/ppdet/data/source/coco.py +0 -251
  1460. paddlex/ppdet/data/source/dataset.py +0 -197
  1461. paddlex/ppdet/data/source/keypoint_coco.py +0 -669
  1462. paddlex/ppdet/data/source/mot.py +0 -636
  1463. paddlex/ppdet/data/source/sniper_coco.py +0 -191
  1464. paddlex/ppdet/data/source/voc.py +0 -231
  1465. paddlex/ppdet/data/source/widerface.py +0 -180
  1466. paddlex/ppdet/data/transform/__init__.py +0 -28
  1467. paddlex/ppdet/data/transform/atss_assigner.py +0 -270
  1468. paddlex/ppdet/data/transform/autoaugment_utils.py +0 -1591
  1469. paddlex/ppdet/data/transform/batch_operators.py +0 -1080
  1470. paddlex/ppdet/data/transform/gridmask_utils.py +0 -86
  1471. paddlex/ppdet/data/transform/keypoint_operators.py +0 -868
  1472. paddlex/ppdet/data/transform/mot_operators.py +0 -628
  1473. paddlex/ppdet/data/transform/op_helper.py +0 -498
  1474. paddlex/ppdet/data/transform/operators.py +0 -3025
  1475. paddlex/ppdet/engine/__init__.py +0 -30
  1476. paddlex/ppdet/engine/callbacks.py +0 -340
  1477. paddlex/ppdet/engine/env.py +0 -50
  1478. paddlex/ppdet/engine/export_utils.py +0 -177
  1479. paddlex/ppdet/engine/tracker.py +0 -538
  1480. paddlex/ppdet/engine/trainer.py +0 -723
  1481. paddlex/ppdet/metrics/__init__.py +0 -29
  1482. paddlex/ppdet/metrics/coco_utils.py +0 -184
  1483. paddlex/ppdet/metrics/json_results.py +0 -149
  1484. paddlex/ppdet/metrics/keypoint_metrics.py +0 -401
  1485. paddlex/ppdet/metrics/map_utils.py +0 -444
  1486. paddlex/ppdet/metrics/mcmot_metrics.py +0 -470
  1487. paddlex/ppdet/metrics/metrics.py +0 -434
  1488. paddlex/ppdet/metrics/mot_metrics.py +0 -1236
  1489. paddlex/ppdet/metrics/munkres.py +0 -428
  1490. paddlex/ppdet/metrics/widerface_utils.py +0 -393
  1491. paddlex/ppdet/model_zoo/__init__.py +0 -18
  1492. paddlex/ppdet/model_zoo/model_zoo.py +0 -84
  1493. paddlex/ppdet/modeling/__init__.py +0 -45
  1494. paddlex/ppdet/modeling/architectures/__init__.py +0 -51
  1495. paddlex/ppdet/modeling/architectures/blazeface.py +0 -91
  1496. paddlex/ppdet/modeling/architectures/cascade_rcnn.py +0 -144
  1497. paddlex/ppdet/modeling/architectures/centernet.py +0 -108
  1498. paddlex/ppdet/modeling/architectures/deepsort.py +0 -69
  1499. paddlex/ppdet/modeling/architectures/detr.py +0 -93
  1500. paddlex/ppdet/modeling/architectures/fairmot.py +0 -100
  1501. paddlex/ppdet/modeling/architectures/faster_rcnn.py +0 -106
  1502. paddlex/ppdet/modeling/architectures/fcos.py +0 -105
  1503. paddlex/ppdet/modeling/architectures/gfl.py +0 -87
  1504. paddlex/ppdet/modeling/architectures/jde.py +0 -111
  1505. paddlex/ppdet/modeling/architectures/keypoint_hrhrnet.py +0 -287
  1506. paddlex/ppdet/modeling/architectures/keypoint_hrnet.py +0 -267
  1507. paddlex/ppdet/modeling/architectures/mask_rcnn.py +0 -135
  1508. paddlex/ppdet/modeling/architectures/meta_arch.py +0 -128
  1509. paddlex/ppdet/modeling/architectures/picodet.py +0 -91
  1510. paddlex/ppdet/modeling/architectures/s2anet.py +0 -102
  1511. paddlex/ppdet/modeling/architectures/solov2.py +0 -110
  1512. paddlex/ppdet/modeling/architectures/sparse_rcnn.py +0 -99
  1513. paddlex/ppdet/modeling/architectures/ssd.py +0 -93
  1514. paddlex/ppdet/modeling/architectures/tood.py +0 -78
  1515. paddlex/ppdet/modeling/architectures/ttfnet.py +0 -98
  1516. paddlex/ppdet/modeling/architectures/yolo.py +0 -124
  1517. paddlex/ppdet/modeling/assigners/__init__.py +0 -23
  1518. paddlex/ppdet/modeling/assigners/atss_assigner.py +0 -211
  1519. paddlex/ppdet/modeling/assigners/simota_assigner.py +0 -262
  1520. paddlex/ppdet/modeling/assigners/task_aligned_assigner.py +0 -158
  1521. paddlex/ppdet/modeling/assigners/utils.py +0 -195
  1522. paddlex/ppdet/modeling/backbones/__init__.py +0 -49
  1523. paddlex/ppdet/modeling/backbones/blazenet.py +0 -323
  1524. paddlex/ppdet/modeling/backbones/darknet.py +0 -340
  1525. paddlex/ppdet/modeling/backbones/dla.py +0 -244
  1526. paddlex/ppdet/modeling/backbones/esnet.py +0 -290
  1527. paddlex/ppdet/modeling/backbones/ghostnet.py +0 -470
  1528. paddlex/ppdet/modeling/backbones/hardnet.py +0 -224
  1529. paddlex/ppdet/modeling/backbones/hrnet.py +0 -727
  1530. paddlex/ppdet/modeling/backbones/lcnet.py +0 -259
  1531. paddlex/ppdet/modeling/backbones/lite_hrnet.py +0 -886
  1532. paddlex/ppdet/modeling/backbones/mobilenet_v1.py +0 -418
  1533. paddlex/ppdet/modeling/backbones/mobilenet_v3.py +0 -483
  1534. paddlex/ppdet/modeling/backbones/name_adapter.py +0 -69
  1535. paddlex/ppdet/modeling/backbones/res2net.py +0 -358
  1536. paddlex/ppdet/modeling/backbones/resnet.py +0 -613
  1537. paddlex/ppdet/modeling/backbones/senet.py +0 -139
  1538. paddlex/ppdet/modeling/backbones/shufflenet_v2.py +0 -246
  1539. paddlex/ppdet/modeling/backbones/swin_transformer.py +0 -743
  1540. paddlex/ppdet/modeling/backbones/vgg.py +0 -210
  1541. paddlex/ppdet/modeling/bbox_utils.py +0 -778
  1542. paddlex/ppdet/modeling/heads/__init__.py +0 -53
  1543. paddlex/ppdet/modeling/heads/bbox_head.py +0 -377
  1544. paddlex/ppdet/modeling/heads/cascade_head.py +0 -284
  1545. paddlex/ppdet/modeling/heads/centernet_head.py +0 -292
  1546. paddlex/ppdet/modeling/heads/detr_head.py +0 -368
  1547. paddlex/ppdet/modeling/heads/face_head.py +0 -110
  1548. paddlex/ppdet/modeling/heads/fcos_head.py +0 -259
  1549. paddlex/ppdet/modeling/heads/gfl_head.py +0 -487
  1550. paddlex/ppdet/modeling/heads/keypoint_hrhrnet_head.py +0 -108
  1551. paddlex/ppdet/modeling/heads/mask_head.py +0 -250
  1552. paddlex/ppdet/modeling/heads/pico_head.py +0 -278
  1553. paddlex/ppdet/modeling/heads/roi_extractor.py +0 -111
  1554. paddlex/ppdet/modeling/heads/s2anet_head.py +0 -1056
  1555. paddlex/ppdet/modeling/heads/simota_head.py +0 -506
  1556. paddlex/ppdet/modeling/heads/solov2_head.py +0 -560
  1557. paddlex/ppdet/modeling/heads/sparsercnn_head.py +0 -375
  1558. paddlex/ppdet/modeling/heads/ssd_head.py +0 -215
  1559. paddlex/ppdet/modeling/heads/tood_head.py +0 -366
  1560. paddlex/ppdet/modeling/heads/ttf_head.py +0 -316
  1561. paddlex/ppdet/modeling/heads/yolo_head.py +0 -124
  1562. paddlex/ppdet/modeling/initializer.py +0 -317
  1563. paddlex/ppdet/modeling/keypoint_utils.py +0 -342
  1564. paddlex/ppdet/modeling/layers.py +0 -1430
  1565. paddlex/ppdet/modeling/losses/__init__.py +0 -43
  1566. paddlex/ppdet/modeling/losses/ctfocal_loss.py +0 -68
  1567. paddlex/ppdet/modeling/losses/detr_loss.py +0 -233
  1568. paddlex/ppdet/modeling/losses/fairmot_loss.py +0 -41
  1569. paddlex/ppdet/modeling/losses/fcos_loss.py +0 -225
  1570. paddlex/ppdet/modeling/losses/gfocal_loss.py +0 -217
  1571. paddlex/ppdet/modeling/losses/iou_aware_loss.py +0 -47
  1572. paddlex/ppdet/modeling/losses/iou_loss.py +0 -210
  1573. paddlex/ppdet/modeling/losses/jde_loss.py +0 -193
  1574. paddlex/ppdet/modeling/losses/keypoint_loss.py +0 -229
  1575. paddlex/ppdet/modeling/losses/solov2_loss.py +0 -101
  1576. paddlex/ppdet/modeling/losses/sparsercnn_loss.py +0 -425
  1577. paddlex/ppdet/modeling/losses/ssd_loss.py +0 -170
  1578. paddlex/ppdet/modeling/losses/varifocal_loss.py +0 -152
  1579. paddlex/ppdet/modeling/losses/yolo_loss.py +0 -212
  1580. paddlex/ppdet/modeling/mot/__init__.py +0 -25
  1581. paddlex/ppdet/modeling/mot/matching/__init__.py +0 -19
  1582. paddlex/ppdet/modeling/mot/matching/deepsort_matching.py +0 -382
  1583. paddlex/ppdet/modeling/mot/matching/jde_matching.py +0 -144
  1584. paddlex/ppdet/modeling/mot/motion/__init__.py +0 -17
  1585. paddlex/ppdet/modeling/mot/motion/kalman_filter.py +0 -270
  1586. paddlex/ppdet/modeling/mot/tracker/__init__.py +0 -23
  1587. paddlex/ppdet/modeling/mot/tracker/base_jde_tracker.py +0 -297
  1588. paddlex/ppdet/modeling/mot/tracker/base_sde_tracker.py +0 -156
  1589. paddlex/ppdet/modeling/mot/tracker/deepsort_tracker.py +0 -188
  1590. paddlex/ppdet/modeling/mot/tracker/jde_tracker.py +0 -277
  1591. paddlex/ppdet/modeling/mot/utils.py +0 -263
  1592. paddlex/ppdet/modeling/mot/visualization.py +0 -150
  1593. paddlex/ppdet/modeling/necks/__init__.py +0 -30
  1594. paddlex/ppdet/modeling/necks/bifpn.py +0 -302
  1595. paddlex/ppdet/modeling/necks/blazeface_fpn.py +0 -216
  1596. paddlex/ppdet/modeling/necks/centernet_fpn.py +0 -426
  1597. paddlex/ppdet/modeling/necks/csp_pan.py +0 -364
  1598. paddlex/ppdet/modeling/necks/fpn.py +0 -231
  1599. paddlex/ppdet/modeling/necks/hrfpn.py +0 -126
  1600. paddlex/ppdet/modeling/necks/ttf_fpn.py +0 -242
  1601. paddlex/ppdet/modeling/necks/yolo_fpn.py +0 -988
  1602. paddlex/ppdet/modeling/ops.py +0 -1611
  1603. paddlex/ppdet/modeling/post_process.py +0 -731
  1604. paddlex/ppdet/modeling/proposal_generator/__init__.py +0 -2
  1605. paddlex/ppdet/modeling/proposal_generator/anchor_generator.py +0 -135
  1606. paddlex/ppdet/modeling/proposal_generator/proposal_generator.py +0 -77
  1607. paddlex/ppdet/modeling/proposal_generator/rpn_head.py +0 -260
  1608. paddlex/ppdet/modeling/proposal_generator/target.py +0 -681
  1609. paddlex/ppdet/modeling/proposal_generator/target_layer.py +0 -491
  1610. paddlex/ppdet/modeling/reid/__init__.py +0 -25
  1611. paddlex/ppdet/modeling/reid/fairmot_embedding_head.py +0 -225
  1612. paddlex/ppdet/modeling/reid/jde_embedding_head.py +0 -214
  1613. paddlex/ppdet/modeling/reid/pplcnet_embedding.py +0 -282
  1614. paddlex/ppdet/modeling/reid/pyramidal_embedding.py +0 -144
  1615. paddlex/ppdet/modeling/reid/resnet.py +0 -310
  1616. paddlex/ppdet/modeling/shape_spec.py +0 -25
  1617. paddlex/ppdet/modeling/transformers/__init__.py +0 -25
  1618. paddlex/ppdet/modeling/transformers/deformable_transformer.py +0 -517
  1619. paddlex/ppdet/modeling/transformers/detr_transformer.py +0 -353
  1620. paddlex/ppdet/modeling/transformers/matchers.py +0 -127
  1621. paddlex/ppdet/modeling/transformers/position_encoding.py +0 -108
  1622. paddlex/ppdet/modeling/transformers/utils.py +0 -110
  1623. paddlex/ppdet/optimizer.py +0 -335
  1624. paddlex/ppdet/slim/__init__.py +0 -82
  1625. paddlex/ppdet/slim/distill.py +0 -110
  1626. paddlex/ppdet/slim/prune.py +0 -85
  1627. paddlex/ppdet/slim/quant.py +0 -84
  1628. paddlex/ppdet/slim/unstructured_prune.py +0 -66
  1629. paddlex/ppdet/utils/__init__.py +0 -13
  1630. paddlex/ppdet/utils/check.py +0 -112
  1631. paddlex/ppdet/utils/checkpoint.py +0 -226
  1632. paddlex/ppdet/utils/cli.py +0 -151
  1633. paddlex/ppdet/utils/colormap.py +0 -58
  1634. paddlex/ppdet/utils/download.py +0 -558
  1635. paddlex/ppdet/utils/logger.py +0 -70
  1636. paddlex/ppdet/utils/profiler.py +0 -111
  1637. paddlex/ppdet/utils/stats.py +0 -94
  1638. paddlex/ppdet/utils/visualizer.py +0 -321
  1639. paddlex/ppdet/utils/voc_utils.py +0 -86
  1640. paddlex/seg.py +0 -41
  1641. paddlex/tools/__init__.py +0 -17
  1642. paddlex/tools/anchor_clustering/__init__.py +0 -15
  1643. paddlex/tools/anchor_clustering/yolo_cluster.py +0 -178
  1644. paddlex/tools/convert.py +0 -52
  1645. paddlex/tools/dataset_conversion/__init__.py +0 -24
  1646. paddlex/tools/dataset_conversion/x2coco.py +0 -379
  1647. paddlex/tools/dataset_conversion/x2imagenet.py +0 -82
  1648. paddlex/tools/dataset_conversion/x2seg.py +0 -343
  1649. paddlex/tools/dataset_conversion/x2voc.py +0 -230
  1650. paddlex/tools/dataset_split/__init__.py +0 -23
  1651. paddlex/tools/dataset_split/coco_split.py +0 -69
  1652. paddlex/tools/dataset_split/imagenet_split.py +0 -75
  1653. paddlex/tools/dataset_split/seg_split.py +0 -96
  1654. paddlex/tools/dataset_split/utils.py +0 -75
  1655. paddlex/tools/dataset_split/voc_split.py +0 -91
  1656. paddlex/tools/split.py +0 -41
  1657. paddlex/utils/checkpoint.py +0 -492
  1658. paddlex/utils/shm.py +0 -67
  1659. paddlex/utils/stats.py +0 -68
  1660. paddlex/utils/utils.py +0 -229
  1661. paddlex-2.1.0.data/data/paddlex_restful/restful/templates/paddlex_restful_demo.html +0 -5205
  1662. paddlex-2.1.0.dist-info/LICENSE +0 -201
  1663. paddlex-2.1.0.dist-info/METADATA +0 -32
  1664. paddlex-2.1.0.dist-info/RECORD +0 -698
  1665. paddlex-2.1.0.dist-info/WHEEL +0 -5
  1666. paddlex-2.1.0.dist-info/entry_points.txt +0 -4
  1667. paddlex-2.1.0.dist-info/top_level.txt +0 -3
  1668. paddlex_restful/__init__.py +0 -15
  1669. paddlex_restful/command.py +0 -63
  1670. paddlex_restful/restful/__init__.py +0 -15
  1671. paddlex_restful/restful/app.py +0 -969
  1672. paddlex_restful/restful/dataset/__init__.py +0 -13
  1673. paddlex_restful/restful/dataset/cls_dataset.py +0 -159
  1674. paddlex_restful/restful/dataset/dataset.py +0 -266
  1675. paddlex_restful/restful/dataset/datasetbase.py +0 -86
  1676. paddlex_restful/restful/dataset/det_dataset.py +0 -190
  1677. paddlex_restful/restful/dataset/ins_seg_dataset.py +0 -312
  1678. paddlex_restful/restful/dataset/operate.py +0 -155
  1679. paddlex_restful/restful/dataset/seg_dataset.py +0 -222
  1680. paddlex_restful/restful/dataset/utils.py +0 -267
  1681. paddlex_restful/restful/demo.py +0 -202
  1682. paddlex_restful/restful/dir.py +0 -45
  1683. paddlex_restful/restful/model.py +0 -312
  1684. paddlex_restful/restful/project/__init__.py +0 -13
  1685. paddlex_restful/restful/project/evaluate/__init__.py +0 -13
  1686. paddlex_restful/restful/project/evaluate/classification.py +0 -126
  1687. paddlex_restful/restful/project/evaluate/detection.py +0 -789
  1688. paddlex_restful/restful/project/evaluate/draw_pred_result.py +0 -181
  1689. paddlex_restful/restful/project/evaluate/segmentation.py +0 -122
  1690. paddlex_restful/restful/project/operate.py +0 -931
  1691. paddlex_restful/restful/project/project.py +0 -143
  1692. paddlex_restful/restful/project/prune/__init__.py +0 -13
  1693. paddlex_restful/restful/project/prune/classification.py +0 -32
  1694. paddlex_restful/restful/project/prune/detection.py +0 -48
  1695. paddlex_restful/restful/project/prune/segmentation.py +0 -34
  1696. paddlex_restful/restful/project/task.py +0 -884
  1697. paddlex_restful/restful/project/train/__init__.py +0 -13
  1698. paddlex_restful/restful/project/train/classification.py +0 -141
  1699. paddlex_restful/restful/project/train/detection.py +0 -263
  1700. paddlex_restful/restful/project/train/params.py +0 -432
  1701. paddlex_restful/restful/project/train/params_v2.py +0 -326
  1702. paddlex_restful/restful/project/train/segmentation.py +0 -191
  1703. paddlex_restful/restful/project/visualize.py +0 -244
  1704. paddlex_restful/restful/system.py +0 -102
  1705. paddlex_restful/restful/templates/paddlex_restful_demo.html +0 -5205
  1706. paddlex_restful/restful/utils.py +0 -841
  1707. paddlex_restful/restful/workspace.py +0 -343
  1708. paddlex_restful/restful/workspace_pb2.py +0 -1411
@@ -1,3025 +0,0 @@
1
- # Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
- # function:
16
- # operators to process sample,
17
- # eg: decode/resize/crop image
18
-
19
- from __future__ import absolute_import
20
- from __future__ import print_function
21
- from __future__ import division
22
-
23
- try:
24
- from collections.abc import Sequence
25
- except Exception:
26
- from collections import Sequence
27
-
28
- from numbers import Number, Integral
29
-
30
- import uuid
31
- import random
32
- import math
33
- import numpy as np
34
- import os
35
- import copy
36
- import logging
37
- import cv2
38
- from PIL import Image, ImageDraw
39
- import pickle
40
- import threading
41
- MUTEX = threading.Lock()
42
-
43
- from paddlex.ppdet.core.workspace import serializable
44
- from paddlex.ppdet.modeling import bbox_utils
45
- from ..reader import Compose
46
-
47
- from .op_helper import (satisfy_sample_constraint, filter_and_process,
48
- generate_sample_bbox, clip_bbox, data_anchor_sampling,
49
- satisfy_sample_constraint_coverage,
50
- crop_image_sampling, generate_sample_bbox_square,
51
- bbox_area_sampling, is_poly, get_border)
52
-
53
- from paddlex.ppdet.utils.logger import setup_logger
54
- from paddlex.ppdet.modeling.keypoint_utils import get_affine_transform, affine_transform
55
- logger = setup_logger(__name__)
56
-
57
- registered_ops = []
58
-
59
-
60
- def register_op(cls):
61
- registered_ops.append(cls.__name__)
62
- if not hasattr(BaseOperator, cls.__name__):
63
- setattr(BaseOperator, cls.__name__, cls)
64
- else:
65
- raise KeyError("The {} class has been registered.".format(
66
- cls.__name__))
67
- return serializable(cls)
68
-
69
-
70
- class BboxError(ValueError):
71
- pass
72
-
73
-
74
- class ImageError(ValueError):
75
- pass
76
-
77
-
78
- class BaseOperator(object):
79
- def __init__(self, name=None):
80
- if name is None:
81
- name = self.__class__.__name__
82
- self._id = name + '_' + str(uuid.uuid4())[-6:]
83
-
84
- def apply(self, sample, context=None):
85
- """ Process a sample.
86
- Args:
87
- sample (dict): a dict of sample, eg: {'image':xx, 'label': xxx}
88
- context (dict): info about this sample processing
89
- Returns:
90
- result (dict): a processed sample
91
- """
92
- return sample
93
-
94
- def __call__(self, sample, context=None):
95
- """ Process a sample.
96
- Args:
97
- sample (dict): a dict of sample, eg: {'image':xx, 'label': xxx}
98
- context (dict): info about this sample processing
99
- Returns:
100
- result (dict): a processed sample
101
- """
102
- if isinstance(sample, Sequence):
103
- for i in range(len(sample)):
104
- sample[i] = self.apply(sample[i], context)
105
- else:
106
- sample = self.apply(sample, context)
107
- return sample
108
-
109
- def __str__(self):
110
- return str(self._id)
111
-
112
-
113
- @register_op
114
- class Decode(BaseOperator):
115
- def __init__(self):
116
- """ Transform the image data to numpy format following the rgb format
117
- """
118
- super(Decode, self).__init__()
119
-
120
- def apply(self, sample, context=None):
121
- """ load image if 'im_file' field is not empty but 'image' is"""
122
- if 'image' not in sample:
123
- with open(sample['im_file'], 'rb') as f:
124
- sample['image'] = f.read()
125
- sample.pop('im_file')
126
-
127
- im = sample['image']
128
- data = np.frombuffer(im, dtype='uint8')
129
- im = cv2.imdecode(data, 1) # BGR mode, but need RGB mode
130
- if 'keep_ori_im' in sample and sample['keep_ori_im']:
131
- sample['ori_image'] = im
132
- im = cv2.cvtColor(im, cv2.COLOR_BGR2RGB)
133
-
134
- sample['image'] = im
135
- if 'h' not in sample:
136
- sample['h'] = im.shape[0]
137
- elif sample['h'] != im.shape[0]:
138
- logger.warning(
139
- "The actual image height: {} is not equal to the "
140
- "height: {} in annotation, and update sample['h'] by actual "
141
- "image height.".format(im.shape[0], sample['h']))
142
- sample['h'] = im.shape[0]
143
- if 'w' not in sample:
144
- sample['w'] = im.shape[1]
145
- elif sample['w'] != im.shape[1]:
146
- logger.warning(
147
- "The actual image width: {} is not equal to the "
148
- "width: {} in annotation, and update sample['w'] by actual "
149
- "image width.".format(im.shape[1], sample['w']))
150
- sample['w'] = im.shape[1]
151
-
152
- sample['im_shape'] = np.array(im.shape[:2], dtype=np.float32)
153
- sample['scale_factor'] = np.array([1., 1.], dtype=np.float32)
154
- return sample
155
-
156
-
157
- def _make_dirs(dirname):
158
- try:
159
- from pathlib import Path
160
- except ImportError:
161
- from pathlib2 import Path
162
- Path(dirname).mkdir(exist_ok=True)
163
-
164
-
165
- @register_op
166
- class DecodeCache(BaseOperator):
167
- def __init__(self, cache_root=None):
168
- '''decode image and caching
169
- '''
170
- super(DecodeCache, self).__init__()
171
-
172
- self.use_cache = False if cache_root is None else True
173
- self.cache_root = cache_root
174
-
175
- if cache_root is not None:
176
- _make_dirs(cache_root)
177
-
178
- def apply(self, sample, context=None):
179
-
180
- if self.use_cache and os.path.exists(
181
- self.cache_path(self.cache_root, sample['im_file'])):
182
- path = self.cache_path(self.cache_root, sample['im_file'])
183
- im = self.load(path)
184
-
185
- else:
186
- if 'image' not in sample:
187
- with open(sample['im_file'], 'rb') as f:
188
- sample['image'] = f.read()
189
-
190
- im = sample['image']
191
- data = np.frombuffer(im, dtype='uint8')
192
- im = cv2.imdecode(data, 1) # BGR mode, but need RGB mode
193
- if 'keep_ori_im' in sample and sample['keep_ori_im']:
194
- sample['ori_image'] = im
195
- im = cv2.cvtColor(im, cv2.COLOR_BGR2RGB)
196
-
197
- if self.use_cache and not os.path.exists(
198
- self.cache_path(self.cache_root, sample['im_file'])):
199
- path = self.cache_path(self.cache_root, sample['im_file'])
200
- self.dump(im, path)
201
-
202
- sample['image'] = im
203
- sample['h'] = im.shape[0]
204
- sample['w'] = im.shape[1]
205
-
206
- sample['im_shape'] = np.array(im.shape[:2], dtype=np.float32)
207
- sample['scale_factor'] = np.array([1., 1.], dtype=np.float32)
208
-
209
- sample.pop('im_file')
210
-
211
- return sample
212
-
213
- @staticmethod
214
- def cache_path(dir_oot, im_file):
215
- return os.path.join(dir_oot, os.path.basename(im_file) + '.pkl')
216
-
217
- @staticmethod
218
- def load(path):
219
- with open(path, 'rb') as f:
220
- im = pickle.load(f)
221
- return im
222
-
223
- @staticmethod
224
- def dump(obj, path):
225
- MUTEX.acquire()
226
- try:
227
- with open(path, 'wb') as f:
228
- pickle.dump(obj, f)
229
-
230
- except Exception as e:
231
- logger.warning('dump {} occurs exception {}'.format(path, str(e)))
232
-
233
- finally:
234
- MUTEX.release()
235
-
236
-
237
- @register_op
238
- class SniperDecodeCrop(BaseOperator):
239
- def __init__(self):
240
- super(SniperDecodeCrop, self).__init__()
241
-
242
- def __call__(self, sample, context=None):
243
- if 'image' not in sample:
244
- with open(sample['im_file'], 'rb') as f:
245
- sample['image'] = f.read()
246
- sample.pop('im_file')
247
-
248
- im = sample['image']
249
- data = np.frombuffer(im, dtype='uint8')
250
- im = cv2.imdecode(data,
251
- cv2.IMREAD_COLOR) # BGR mode, but need RGB mode
252
- if 'keep_ori_im' in sample and sample['keep_ori_im']:
253
- sample['ori_image'] = im
254
- im = cv2.cvtColor(im, cv2.COLOR_BGR2RGB)
255
-
256
- chip = sample['chip']
257
- x1, y1, x2, y2 = [int(xi) for xi in chip]
258
- im = im[max(y1, 0):min(y2, im.shape[0]), max(x1, 0):min(x2, im.shape[
259
- 1]), :]
260
-
261
- sample['image'] = im
262
- h = im.shape[0]
263
- w = im.shape[1]
264
- # sample['im_info'] = [h, w, 1.0]
265
- sample['h'] = h
266
- sample['w'] = w
267
-
268
- sample['im_shape'] = np.array(im.shape[:2], dtype=np.float32)
269
- sample['scale_factor'] = np.array([1., 1.], dtype=np.float32)
270
- return sample
271
-
272
-
273
- @register_op
274
- class Permute(BaseOperator):
275
- def __init__(self):
276
- """
277
- Change the channel to be (C, H, W)
278
- """
279
- super(Permute, self).__init__()
280
-
281
- def apply(self, sample, context=None):
282
- im = sample['image']
283
- im = im.transpose((2, 0, 1))
284
- sample['image'] = im
285
- return sample
286
-
287
-
288
- @register_op
289
- class Lighting(BaseOperator):
290
- """
291
- Lighting the image by eigenvalues and eigenvectors
292
- Args:
293
- eigval (list): eigenvalues
294
- eigvec (list): eigenvectors
295
- alphastd (float): random weight of lighting, 0.1 by default
296
- """
297
-
298
- def __init__(self, eigval, eigvec, alphastd=0.1):
299
- super(Lighting, self).__init__()
300
- self.alphastd = alphastd
301
- self.eigval = np.array(eigval).astype('float32')
302
- self.eigvec = np.array(eigvec).astype('float32')
303
-
304
- def apply(self, sample, context=None):
305
- alpha = np.random.normal(scale=self.alphastd, size=(3, ))
306
- sample['image'] += np.dot(self.eigvec, self.eigval * alpha)
307
- return sample
308
-
309
-
310
- @register_op
311
- class RandomErasingImage(BaseOperator):
312
- def __init__(self, prob=0.5, lower=0.02, higher=0.4, aspect_ratio=0.3):
313
- """
314
- Random Erasing Data Augmentation, see https://arxiv.org/abs/1708.04896
315
- Args:
316
- prob (float): probability to carry out random erasing
317
- lower (float): lower limit of the erasing area ratio
318
- higher (float): upper limit of the erasing area ratio
319
- aspect_ratio (float): aspect ratio of the erasing region
320
- """
321
- super(RandomErasingImage, self).__init__()
322
- self.prob = prob
323
- self.lower = lower
324
- self.higher = higher
325
- self.aspect_ratio = aspect_ratio
326
-
327
- def apply(self, sample):
328
- gt_bbox = sample['gt_bbox']
329
- im = sample['image']
330
- if not isinstance(im, np.ndarray):
331
- raise TypeError("{}: image is not a numpy array.".format(self))
332
- if len(im.shape) != 3:
333
- raise ImageError("{}: image is not 3-dimensional.".format(self))
334
-
335
- for idx in range(gt_bbox.shape[0]):
336
- if self.prob <= np.random.rand():
337
- continue
338
-
339
- x1, y1, x2, y2 = gt_bbox[idx, :]
340
- w_bbox = x2 - x1
341
- h_bbox = y2 - y1
342
- area = w_bbox * h_bbox
343
-
344
- target_area = random.uniform(self.lower, self.higher) * area
345
- aspect_ratio = random.uniform(self.aspect_ratio,
346
- 1 / self.aspect_ratio)
347
-
348
- h = int(round(math.sqrt(target_area * aspect_ratio)))
349
- w = int(round(math.sqrt(target_area / aspect_ratio)))
350
-
351
- if w < w_bbox and h < h_bbox:
352
- off_y1 = random.randint(0, int(h_bbox - h))
353
- off_x1 = random.randint(0, int(w_bbox - w))
354
- im[int(y1 + off_y1):int(y1 + off_y1 + h), int(x1 + off_x1):int(
355
- x1 + off_x1 + w), :] = 0
356
- sample['image'] = im
357
- return sample
358
-
359
-
360
- @register_op
361
- class NormalizeImage(BaseOperator):
362
- def __init__(self,
363
- mean=[0.485, 0.456, 0.406],
364
- std=[1, 1, 1],
365
- is_scale=True):
366
- """
367
- Args:
368
- mean (list): the pixel mean
369
- std (list): the pixel variance
370
- """
371
- super(NormalizeImage, self).__init__()
372
- self.mean = mean
373
- self.std = std
374
- self.is_scale = is_scale
375
- if not (isinstance(self.mean, list) and isinstance(self.std, list) and
376
- isinstance(self.is_scale, bool)):
377
- raise TypeError("{}: input type is invalid.".format(self))
378
- from functools import reduce
379
- if reduce(lambda x, y: x * y, self.std) == 0:
380
- raise ValueError('{}: std is invalid!'.format(self))
381
-
382
- def apply(self, sample, context=None):
383
- """Normalize the image.
384
- Operators:
385
- 1.(optional) Scale the image to [0,1]
386
- 2. Each pixel minus mean and is divided by std
387
- """
388
- im = sample['image']
389
- im = im.astype(np.float32, copy=False)
390
- mean = np.array(self.mean)[np.newaxis, np.newaxis, :]
391
- std = np.array(self.std)[np.newaxis, np.newaxis, :]
392
-
393
- if self.is_scale:
394
- im = im / 255.0
395
-
396
- im -= mean
397
- im /= std
398
-
399
- sample['image'] = im
400
- return sample
401
-
402
-
403
- @register_op
404
- class GridMask(BaseOperator):
405
- def __init__(self,
406
- use_h=True,
407
- use_w=True,
408
- rotate=1,
409
- offset=False,
410
- ratio=0.5,
411
- mode=1,
412
- prob=0.7,
413
- upper_iter=360000):
414
- """
415
- GridMask Data Augmentation, see https://arxiv.org/abs/2001.04086
416
- Args:
417
- use_h (bool): whether to mask vertically
418
- use_w (boo;): whether to mask horizontally
419
- rotate (float): angle for the mask to rotate
420
- offset (float): mask offset
421
- ratio (float): mask ratio
422
- mode (int): gridmask mode
423
- prob (float): max probability to carry out gridmask
424
- upper_iter (int): suggested to be equal to global max_iter
425
- """
426
- super(GridMask, self).__init__()
427
- self.use_h = use_h
428
- self.use_w = use_w
429
- self.rotate = rotate
430
- self.offset = offset
431
- self.ratio = ratio
432
- self.mode = mode
433
- self.prob = prob
434
- self.upper_iter = upper_iter
435
-
436
- from .gridmask_utils import Gridmask
437
- self.gridmask_op = Gridmask(
438
- use_h,
439
- use_w,
440
- rotate=rotate,
441
- offset=offset,
442
- ratio=ratio,
443
- mode=mode,
444
- prob=prob,
445
- upper_iter=upper_iter)
446
-
447
- def apply(self, sample, context=None):
448
- sample['image'] = self.gridmask_op(sample['image'],
449
- sample['curr_iter'])
450
- return sample
451
-
452
-
453
- @register_op
454
- class RandomDistort(BaseOperator):
455
- """Random color distortion.
456
- Args:
457
- hue (list): hue settings. in [lower, upper, probability] format.
458
- saturation (list): saturation settings. in [lower, upper, probability] format.
459
- contrast (list): contrast settings. in [lower, upper, probability] format.
460
- brightness (list): brightness settings. in [lower, upper, probability] format.
461
- random_apply (bool): whether to apply in random (yolo) or fixed (SSD)
462
- order.
463
- count (int): the number of doing distrot
464
- random_channel (bool): whether to swap channels randomly
465
- """
466
-
467
- def __init__(self,
468
- hue=[-18, 18, 0.5],
469
- saturation=[0.5, 1.5, 0.5],
470
- contrast=[0.5, 1.5, 0.5],
471
- brightness=[0.5, 1.5, 0.5],
472
- random_apply=True,
473
- count=4,
474
- random_channel=False):
475
- super(RandomDistort, self).__init__()
476
- self.hue = hue
477
- self.saturation = saturation
478
- self.contrast = contrast
479
- self.brightness = brightness
480
- self.random_apply = random_apply
481
- self.count = count
482
- self.random_channel = random_channel
483
-
484
- def apply_hue(self, img):
485
- low, high, prob = self.hue
486
- if np.random.uniform(0., 1.) < prob:
487
- return img
488
-
489
- img = img.astype(np.float32)
490
- # it works, but result differ from HSV version
491
- delta = np.random.uniform(low, high)
492
- u = np.cos(delta * np.pi)
493
- w = np.sin(delta * np.pi)
494
- bt = np.array([[1.0, 0.0, 0.0], [0.0, u, -w], [0.0, w, u]])
495
- tyiq = np.array([[0.299, 0.587, 0.114], [0.596, -0.274, -0.321],
496
- [0.211, -0.523, 0.311]])
497
- ityiq = np.array([[1.0, 0.956, 0.621], [1.0, -0.272, -0.647],
498
- [1.0, -1.107, 1.705]])
499
- t = np.dot(np.dot(ityiq, bt), tyiq).T
500
- img = np.dot(img, t)
501
- return img
502
-
503
- def apply_saturation(self, img):
504
- low, high, prob = self.saturation
505
- if np.random.uniform(0., 1.) < prob:
506
- return img
507
- delta = np.random.uniform(low, high)
508
- img = img.astype(np.float32)
509
- # it works, but result differ from HSV version
510
- gray = img * np.array([[[0.299, 0.587, 0.114]]], dtype=np.float32)
511
- gray = gray.sum(axis=2, keepdims=True)
512
- gray *= (1.0 - delta)
513
- img *= delta
514
- img += gray
515
- return img
516
-
517
- def apply_contrast(self, img):
518
- low, high, prob = self.contrast
519
- if np.random.uniform(0., 1.) < prob:
520
- return img
521
- delta = np.random.uniform(low, high)
522
- img = img.astype(np.float32)
523
- img *= delta
524
- return img
525
-
526
- def apply_brightness(self, img):
527
- low, high, prob = self.brightness
528
- if np.random.uniform(0., 1.) < prob:
529
- return img
530
- delta = np.random.uniform(low, high)
531
- img = img.astype(np.float32)
532
- img += delta
533
- return img
534
-
535
- def apply(self, sample, context=None):
536
- img = sample['image']
537
- if self.random_apply:
538
- functions = [
539
- self.apply_brightness, self.apply_contrast,
540
- self.apply_saturation, self.apply_hue
541
- ]
542
- distortions = np.random.permutation(functions)[:self.count]
543
- for func in distortions:
544
- img = func(img)
545
- sample['image'] = img
546
- return sample
547
-
548
- img = self.apply_brightness(img)
549
- mode = np.random.randint(0, 2)
550
-
551
- if mode:
552
- img = self.apply_contrast(img)
553
-
554
- img = self.apply_saturation(img)
555
- img = self.apply_hue(img)
556
-
557
- if not mode:
558
- img = self.apply_contrast(img)
559
-
560
- if self.random_channel:
561
- if np.random.randint(0, 2):
562
- img = img[..., np.random.permutation(3)]
563
- sample['image'] = img
564
- return sample
565
-
566
-
567
- @register_op
568
- class AutoAugment(BaseOperator):
569
- def __init__(self, autoaug_type="v1"):
570
- """
571
- Args:
572
- autoaug_type (str): autoaug type, support v0, v1, v2, v3, test
573
- """
574
- super(AutoAugment, self).__init__()
575
- self.autoaug_type = autoaug_type
576
-
577
- def apply(self, sample, context=None):
578
- """
579
- Learning Data Augmentation Strategies for Object Detection, see https://arxiv.org/abs/1906.11172
580
- """
581
- im = sample['image']
582
- gt_bbox = sample['gt_bbox']
583
- if not isinstance(im, np.ndarray):
584
- raise TypeError("{}: image is not a numpy array.".format(self))
585
- if len(im.shape) != 3:
586
- raise ImageError("{}: image is not 3-dimensional.".format(self))
587
- if len(gt_bbox) == 0:
588
- return sample
589
-
590
- height, width, _ = im.shape
591
- norm_gt_bbox = np.ones_like(gt_bbox, dtype=np.float32)
592
- norm_gt_bbox[:, 0] = gt_bbox[:, 1] / float(height)
593
- norm_gt_bbox[:, 1] = gt_bbox[:, 0] / float(width)
594
- norm_gt_bbox[:, 2] = gt_bbox[:, 3] / float(height)
595
- norm_gt_bbox[:, 3] = gt_bbox[:, 2] / float(width)
596
-
597
- from .autoaugment_utils import distort_image_with_autoaugment
598
- im, norm_gt_bbox = distort_image_with_autoaugment(im, norm_gt_bbox,
599
- self.autoaug_type)
600
-
601
- gt_bbox[:, 0] = norm_gt_bbox[:, 1] * float(width)
602
- gt_bbox[:, 1] = norm_gt_bbox[:, 0] * float(height)
603
- gt_bbox[:, 2] = norm_gt_bbox[:, 3] * float(width)
604
- gt_bbox[:, 3] = norm_gt_bbox[:, 2] * float(height)
605
-
606
- sample['image'] = im
607
- sample['gt_bbox'] = gt_bbox
608
- return sample
609
-
610
-
611
- @register_op
612
- class RandomFlip(BaseOperator):
613
- def __init__(self, prob=0.5):
614
- """
615
- Args:
616
- prob (float): the probability of flipping image
617
- """
618
- super(RandomFlip, self).__init__()
619
- self.prob = prob
620
- if not (isinstance(self.prob, float)):
621
- raise TypeError("{}: input type is invalid.".format(self))
622
-
623
- def apply_segm(self, segms, height, width):
624
- def _flip_poly(poly, width):
625
- flipped_poly = np.array(poly)
626
- flipped_poly[0::2] = width - np.array(poly[0::2])
627
- return flipped_poly.tolist()
628
-
629
- def _flip_rle(rle, height, width):
630
- if 'counts' in rle and type(rle['counts']) == list:
631
- rle = mask_util.frPyObjects(rle, height, width)
632
- mask = mask_util.decode(rle)
633
- mask = mask[:, ::-1]
634
- rle = mask_util.encode(np.array(mask, order='F', dtype=np.uint8))
635
- return rle
636
-
637
- flipped_segms = []
638
- for segm in segms:
639
- if is_poly(segm):
640
- # Polygon format
641
- flipped_segms.append(
642
- [_flip_poly(poly, width) for poly in segm])
643
- else:
644
- # RLE format
645
- import pycocotools.mask as mask_util
646
- flipped_segms.append(_flip_rle(segm, height, width))
647
- return flipped_segms
648
-
649
- def apply_keypoint(self, gt_keypoint, width):
650
- for i in range(gt_keypoint.shape[1]):
651
- if i % 2 == 0:
652
- old_x = gt_keypoint[:, i].copy()
653
- gt_keypoint[:, i] = width - old_x
654
- return gt_keypoint
655
-
656
- def apply_image(self, image):
657
- return image[:, ::-1, :]
658
-
659
- def apply_bbox(self, bbox, width):
660
- oldx1 = bbox[:, 0].copy()
661
- oldx2 = bbox[:, 2].copy()
662
- bbox[:, 0] = width - oldx2
663
- bbox[:, 2] = width - oldx1
664
- return bbox
665
-
666
- def apply_rbox(self, bbox, width):
667
- oldx1 = bbox[:, 0].copy()
668
- oldx2 = bbox[:, 2].copy()
669
- oldx3 = bbox[:, 4].copy()
670
- oldx4 = bbox[:, 6].copy()
671
- bbox[:, 0] = width - oldx1
672
- bbox[:, 2] = width - oldx2
673
- bbox[:, 4] = width - oldx3
674
- bbox[:, 6] = width - oldx4
675
- bbox = [bbox_utils.get_best_begin_point_single(e) for e in bbox]
676
- return bbox
677
-
678
- def apply(self, sample, context=None):
679
- """Filp the image and bounding box.
680
- Operators:
681
- 1. Flip the image numpy.
682
- 2. Transform the bboxes' x coordinates.
683
- (Must judge whether the coordinates are normalized!)
684
- 3. Transform the segmentations' x coordinates.
685
- (Must judge whether the coordinates are normalized!)
686
- Output:
687
- sample: the image, bounding box and segmentation part
688
- in sample are flipped.
689
- """
690
- if np.random.uniform(0, 1) < self.prob:
691
- im = sample['image']
692
- height, width = im.shape[:2]
693
- im = self.apply_image(im)
694
- if 'gt_bbox' in sample and len(sample['gt_bbox']) > 0:
695
- sample['gt_bbox'] = self.apply_bbox(sample['gt_bbox'], width)
696
- if 'gt_poly' in sample and len(sample['gt_poly']) > 0:
697
- sample['gt_poly'] = self.apply_segm(sample['gt_poly'], height,
698
- width)
699
- if 'gt_keypoint' in sample and len(sample['gt_keypoint']) > 0:
700
- sample['gt_keypoint'] = self.apply_keypoint(
701
- sample['gt_keypoint'], width)
702
-
703
- if 'semantic' in sample and sample['semantic']:
704
- sample['semantic'] = sample['semantic'][:, ::-1]
705
-
706
- if 'gt_segm' in sample and sample['gt_segm'].any():
707
- sample['gt_segm'] = sample['gt_segm'][:, :, ::-1]
708
-
709
- if 'gt_rbox2poly' in sample and sample['gt_rbox2poly'].any():
710
- sample['gt_rbox2poly'] = self.apply_rbox(
711
- sample['gt_rbox2poly'], width)
712
-
713
- sample['flipped'] = True
714
- sample['image'] = im
715
- return sample
716
-
717
-
718
- @register_op
719
- class Resize(BaseOperator):
720
- def __init__(self, target_size, keep_ratio, interp=cv2.INTER_LINEAR):
721
- """
722
- Resize image to target size. if keep_ratio is True,
723
- resize the image's long side to the maximum of target_size
724
- if keep_ratio is False, resize the image to target size(h, w)
725
- Args:
726
- target_size (int|list): image target size
727
- keep_ratio (bool): whether keep_ratio or not, default true
728
- interp (int): the interpolation method
729
- """
730
- super(Resize, self).__init__()
731
- self.keep_ratio = keep_ratio
732
- self.interp = interp
733
- if not isinstance(target_size, (Integral, Sequence)):
734
- raise TypeError(
735
- "Type of target_size is invalid. Must be Integer or List or Tuple, now is {}".
736
- format(type(target_size)))
737
- if isinstance(target_size, Integral):
738
- target_size = [target_size, target_size]
739
- self.target_size = target_size
740
-
741
- def apply_image(self, image, scale):
742
- im_scale_x, im_scale_y = scale
743
-
744
- return cv2.resize(
745
- image,
746
- None,
747
- None,
748
- fx=im_scale_x,
749
- fy=im_scale_y,
750
- interpolation=self.interp)
751
-
752
- def apply_bbox(self, bbox, scale, size):
753
- im_scale_x, im_scale_y = scale
754
- resize_w, resize_h = size
755
- bbox[:, 0::2] *= im_scale_x
756
- bbox[:, 1::2] *= im_scale_y
757
- bbox[:, 0::2] = np.clip(bbox[:, 0::2], 0, resize_w)
758
- bbox[:, 1::2] = np.clip(bbox[:, 1::2], 0, resize_h)
759
- return bbox
760
-
761
- def apply_segm(self, segms, im_size, scale):
762
- def _resize_poly(poly, im_scale_x, im_scale_y):
763
- resized_poly = np.array(poly).astype('float32')
764
- resized_poly[0::2] *= im_scale_x
765
- resized_poly[1::2] *= im_scale_y
766
- return resized_poly.tolist()
767
-
768
- def _resize_rle(rle, im_h, im_w, im_scale_x, im_scale_y):
769
- if 'counts' in rle and type(rle['counts']) == list:
770
- rle = mask_util.frPyObjects(rle, im_h, im_w)
771
-
772
- mask = mask_util.decode(rle)
773
- mask = cv2.resize(
774
- mask,
775
- None,
776
- None,
777
- fx=im_scale_x,
778
- fy=im_scale_y,
779
- interpolation=self.interp)
780
- rle = mask_util.encode(np.array(mask, order='F', dtype=np.uint8))
781
- return rle
782
-
783
- im_h, im_w = im_size
784
- im_scale_x, im_scale_y = scale
785
- resized_segms = []
786
- for segm in segms:
787
- if is_poly(segm):
788
- # Polygon format
789
- resized_segms.append([
790
- _resize_poly(poly, im_scale_x, im_scale_y) for poly in segm
791
- ])
792
- else:
793
- # RLE format
794
- import pycocotools.mask as mask_util
795
- resized_segms.append(
796
- _resize_rle(segm, im_h, im_w, im_scale_x, im_scale_y))
797
-
798
- return resized_segms
799
-
800
- def apply(self, sample, context=None):
801
- """ Resize the image numpy.
802
- """
803
- im = sample['image']
804
- if not isinstance(im, np.ndarray):
805
- raise TypeError("{}: image type is not numpy.".format(self))
806
- if len(im.shape) != 3:
807
- raise ImageError('{}: image is not 3-dimensional.'.format(self))
808
-
809
- # apply image
810
- im_shape = im.shape
811
- if self.keep_ratio:
812
-
813
- im_size_min = np.min(im_shape[0:2])
814
- im_size_max = np.max(im_shape[0:2])
815
-
816
- target_size_min = np.min(self.target_size)
817
- target_size_max = np.max(self.target_size)
818
-
819
- im_scale = min(target_size_min / im_size_min,
820
- target_size_max / im_size_max)
821
-
822
- resize_h = im_scale * float(im_shape[0])
823
- resize_w = im_scale * float(im_shape[1])
824
-
825
- im_scale_x = im_scale
826
- im_scale_y = im_scale
827
- else:
828
- resize_h, resize_w = self.target_size
829
- im_scale_y = resize_h / im_shape[0]
830
- im_scale_x = resize_w / im_shape[1]
831
-
832
- im = self.apply_image(sample['image'], [im_scale_x, im_scale_y])
833
- sample['image'] = im
834
- sample['im_shape'] = np.asarray([resize_h, resize_w], dtype=np.float32)
835
- if 'scale_factor' in sample:
836
- scale_factor = sample['scale_factor']
837
- sample['scale_factor'] = np.asarray(
838
- [scale_factor[0] * im_scale_y, scale_factor[1] * im_scale_x],
839
- dtype=np.float32)
840
- else:
841
- sample['scale_factor'] = np.asarray(
842
- [im_scale_y, im_scale_x], dtype=np.float32)
843
-
844
- # apply bbox
845
- if 'gt_bbox' in sample and len(sample['gt_bbox']) > 0:
846
- sample['gt_bbox'] = self.apply_bbox(sample['gt_bbox'],
847
- [im_scale_x, im_scale_y],
848
- [resize_w, resize_h])
849
-
850
- # apply rbox
851
- if 'gt_rbox2poly' in sample:
852
- if np.array(sample['gt_rbox2poly']).shape[1] != 8:
853
- logger.warning(
854
- "gt_rbox2poly's length shoule be 8, but actually is {}".
855
- format(len(sample['gt_rbox2poly'])))
856
- sample['gt_rbox2poly'] = self.apply_bbox(sample['gt_rbox2poly'],
857
- [im_scale_x, im_scale_y],
858
- [resize_w, resize_h])
859
-
860
- # apply polygon
861
- if 'gt_poly' in sample and len(sample['gt_poly']) > 0:
862
- sample['gt_poly'] = self.apply_segm(
863
- sample['gt_poly'], im_shape[:2], [im_scale_x, im_scale_y])
864
-
865
- # apply semantic
866
- if 'semantic' in sample and sample['semantic']:
867
- semantic = sample['semantic']
868
- semantic = cv2.resize(
869
- semantic.astype('float32'),
870
- None,
871
- None,
872
- fx=im_scale_x,
873
- fy=im_scale_y,
874
- interpolation=self.interp)
875
- semantic = np.asarray(semantic).astype('int32')
876
- semantic = np.expand_dims(semantic, 0)
877
- sample['semantic'] = semantic
878
-
879
- # apply gt_segm
880
- if 'gt_segm' in sample and len(sample['gt_segm']) > 0:
881
- masks = [
882
- cv2.resize(
883
- gt_segm,
884
- None,
885
- None,
886
- fx=im_scale_x,
887
- fy=im_scale_y,
888
- interpolation=cv2.INTER_NEAREST)
889
- for gt_segm in sample['gt_segm']
890
- ]
891
- sample['gt_segm'] = np.asarray(masks).astype(np.uint8)
892
-
893
- return sample
894
-
895
-
896
- @register_op
897
- class MultiscaleTestResize(BaseOperator):
898
- def __init__(self,
899
- origin_target_size=[800, 1333],
900
- target_size=[],
901
- interp=cv2.INTER_LINEAR,
902
- use_flip=True):
903
- """
904
- Rescale image to the each size in target size, and capped at max_size.
905
- Args:
906
- origin_target_size (list): origin target size of image
907
- target_size (list): A list of target sizes of image.
908
- interp (int): the interpolation method.
909
- use_flip (bool): whether use flip augmentation.
910
- """
911
- super(MultiscaleTestResize, self).__init__()
912
- self.interp = interp
913
- self.use_flip = use_flip
914
-
915
- if not isinstance(target_size, Sequence):
916
- raise TypeError(
917
- "Type of target_size is invalid. Must be List or Tuple, now is {}".
918
- format(type(target_size)))
919
- self.target_size = target_size
920
-
921
- if not isinstance(origin_target_size, Sequence):
922
- raise TypeError(
923
- "Type of origin_target_size is invalid. Must be List or Tuple, now is {}".
924
- format(type(origin_target_size)))
925
-
926
- self.origin_target_size = origin_target_size
927
-
928
- def apply(self, sample, context=None):
929
- """ Resize the image numpy for multi-scale test.
930
- """
931
- samples = []
932
- resizer = Resize(
933
- self.origin_target_size, keep_ratio=True, interp=self.interp)
934
- samples.append(resizer(sample.copy(), context))
935
- if self.use_flip:
936
- flipper = RandomFlip(1.1)
937
- samples.append(flipper(sample.copy(), context=context))
938
-
939
- for size in self.target_size:
940
- resizer = Resize(size, keep_ratio=True, interp=self.interp)
941
- samples.append(resizer(sample.copy(), context))
942
-
943
- return samples
944
-
945
-
946
- @register_op
947
- class RandomResize(BaseOperator):
948
- def __init__(self,
949
- target_size,
950
- keep_ratio=True,
951
- interp=cv2.INTER_LINEAR,
952
- random_size=True,
953
- random_interp=False):
954
- """
955
- Resize image to target size randomly. random target_size and interpolation method
956
- Args:
957
- target_size (int, list, tuple): image target size, if random size is True, must be list or tuple
958
- keep_ratio (bool): whether keep_raio or not, default true
959
- interp (int): the interpolation method
960
- random_size (bool): whether random select target size of image
961
- random_interp (bool): whether random select interpolation method
962
- """
963
- super(RandomResize, self).__init__()
964
- self.keep_ratio = keep_ratio
965
- self.interp = interp
966
- self.interps = [
967
- cv2.INTER_NEAREST,
968
- cv2.INTER_LINEAR,
969
- cv2.INTER_AREA,
970
- cv2.INTER_CUBIC,
971
- cv2.INTER_LANCZOS4,
972
- ]
973
- assert isinstance(target_size, (
974
- Integral, Sequence)), "target_size must be Integer, List or Tuple"
975
- if random_size and not isinstance(target_size, Sequence):
976
- raise TypeError(
977
- "Type of target_size is invalid when random_size is True. Must be List or Tuple, now is {}".
978
- format(type(target_size)))
979
- self.target_size = target_size
980
- self.random_size = random_size
981
- self.random_interp = random_interp
982
-
983
- def apply(self, sample, context=None):
984
- """ Resize the image numpy.
985
- """
986
- if self.random_size:
987
- target_size = random.choice(self.target_size)
988
- else:
989
- target_size = self.target_size
990
-
991
- if self.random_interp:
992
- interp = random.choice(self.interps)
993
- else:
994
- interp = self.interp
995
-
996
- resizer = Resize(target_size, self.keep_ratio, interp)
997
- return resizer(sample, context=context)
998
-
999
-
1000
- @register_op
1001
- class RandomExpand(BaseOperator):
1002
- """Random expand the canvas.
1003
- Args:
1004
- ratio (float): maximum expansion ratio.
1005
- prob (float): probability to expand.
1006
- fill_value (list): color value used to fill the canvas. in RGB order.
1007
- """
1008
-
1009
- def __init__(self, ratio=4., prob=0.5, fill_value=(127.5, 127.5, 127.5)):
1010
- super(RandomExpand, self).__init__()
1011
- assert ratio > 1.01, "expand ratio must be larger than 1.01"
1012
- self.ratio = ratio
1013
- self.prob = prob
1014
- assert isinstance(fill_value, (Number, Sequence)), \
1015
- "fill value must be either float or sequence"
1016
- if isinstance(fill_value, Number):
1017
- fill_value = (fill_value, ) * 3
1018
- if not isinstance(fill_value, tuple):
1019
- fill_value = tuple(fill_value)
1020
- self.fill_value = fill_value
1021
-
1022
- def apply(self, sample, context=None):
1023
- if np.random.uniform(0., 1.) < self.prob:
1024
- return sample
1025
-
1026
- im = sample['image']
1027
- height, width = im.shape[:2]
1028
- ratio = np.random.uniform(1., self.ratio)
1029
- h = int(height * ratio)
1030
- w = int(width * ratio)
1031
- if not h > height or not w > width:
1032
- return sample
1033
- y = np.random.randint(0, h - height)
1034
- x = np.random.randint(0, w - width)
1035
- offsets, size = [x, y], [h, w]
1036
-
1037
- pad = Pad(size,
1038
- pad_mode=-1,
1039
- offsets=offsets,
1040
- fill_value=self.fill_value)
1041
-
1042
- return pad(sample, context=context)
1043
-
1044
-
1045
- @register_op
1046
- class CropWithSampling(BaseOperator):
1047
- def __init__(self, batch_sampler, satisfy_all=False, avoid_no_bbox=True):
1048
- """
1049
- Args:
1050
- batch_sampler (list): Multiple sets of different
1051
- parameters for cropping.
1052
- satisfy_all (bool): whether all boxes must satisfy.
1053
- e.g.[[1, 1, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0],
1054
- [1, 50, 0.3, 1.0, 0.5, 2.0, 0.1, 1.0],
1055
- [1, 50, 0.3, 1.0, 0.5, 2.0, 0.3, 1.0],
1056
- [1, 50, 0.3, 1.0, 0.5, 2.0, 0.5, 1.0],
1057
- [1, 50, 0.3, 1.0, 0.5, 2.0, 0.7, 1.0],
1058
- [1, 50, 0.3, 1.0, 0.5, 2.0, 0.9, 1.0],
1059
- [1, 50, 0.3, 1.0, 0.5, 2.0, 0.0, 1.0]]
1060
- [max sample, max trial, min scale, max scale,
1061
- min aspect ratio, max aspect ratio,
1062
- min overlap, max overlap]
1063
- avoid_no_bbox (bool): whether to to avoid the
1064
- situation where the box does not appear.
1065
- """
1066
- super(CropWithSampling, self).__init__()
1067
- self.batch_sampler = batch_sampler
1068
- self.satisfy_all = satisfy_all
1069
- self.avoid_no_bbox = avoid_no_bbox
1070
-
1071
- def apply(self, sample, context):
1072
- """
1073
- Crop the image and modify bounding box.
1074
- Operators:
1075
- 1. Scale the image width and height.
1076
- 2. Crop the image according to a radom sample.
1077
- 3. Rescale the bounding box.
1078
- 4. Determine if the new bbox is satisfied in the new image.
1079
- Returns:
1080
- sample: the image, bounding box are replaced.
1081
- """
1082
- assert 'image' in sample, "image data not found"
1083
- im = sample['image']
1084
- gt_bbox = sample['gt_bbox']
1085
- gt_class = sample['gt_class']
1086
- im_height, im_width = im.shape[:2]
1087
- gt_score = None
1088
- if 'gt_score' in sample:
1089
- gt_score = sample['gt_score']
1090
- sampled_bbox = []
1091
- gt_bbox = gt_bbox.tolist()
1092
- for sampler in self.batch_sampler:
1093
- found = 0
1094
- for i in range(sampler[1]):
1095
- if found >= sampler[0]:
1096
- break
1097
- sample_bbox = generate_sample_bbox(sampler)
1098
- if satisfy_sample_constraint(sampler, sample_bbox, gt_bbox,
1099
- self.satisfy_all):
1100
- sampled_bbox.append(sample_bbox)
1101
- found = found + 1
1102
- im = np.array(im)
1103
- while sampled_bbox:
1104
- idx = int(np.random.uniform(0, len(sampled_bbox)))
1105
- sample_bbox = sampled_bbox.pop(idx)
1106
- sample_bbox = clip_bbox(sample_bbox)
1107
- crop_bbox, crop_class, crop_score = \
1108
- filter_and_process(sample_bbox, gt_bbox, gt_class, scores=gt_score)
1109
- if self.avoid_no_bbox:
1110
- if len(crop_bbox) < 1:
1111
- continue
1112
- xmin = int(sample_bbox[0] * im_width)
1113
- xmax = int(sample_bbox[2] * im_width)
1114
- ymin = int(sample_bbox[1] * im_height)
1115
- ymax = int(sample_bbox[3] * im_height)
1116
- im = im[ymin:ymax, xmin:xmax]
1117
- sample['image'] = im
1118
- sample['gt_bbox'] = crop_bbox
1119
- sample['gt_class'] = crop_class
1120
- sample['gt_score'] = crop_score
1121
- return sample
1122
- return sample
1123
-
1124
-
1125
- @register_op
1126
- class CropWithDataAchorSampling(BaseOperator):
1127
- def __init__(self,
1128
- batch_sampler,
1129
- anchor_sampler=None,
1130
- target_size=None,
1131
- das_anchor_scales=[16, 32, 64, 128],
1132
- sampling_prob=0.5,
1133
- min_size=8.,
1134
- avoid_no_bbox=True):
1135
- """
1136
- Args:
1137
- anchor_sampler (list): anchor_sampling sets of different
1138
- parameters for cropping.
1139
- batch_sampler (list): Multiple sets of different
1140
- parameters for cropping.
1141
- e.g.[[1, 10, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.2, 0.0]]
1142
- [[1, 50, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0],
1143
- [1, 50, 0.3, 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0],
1144
- [1, 50, 0.3, 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0],
1145
- [1, 50, 0.3, 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0],
1146
- [1, 50, 0.3, 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0]]
1147
- [max sample, max trial, min scale, max scale,
1148
- min aspect ratio, max aspect ratio,
1149
- min overlap, max overlap, min coverage, max coverage]
1150
- target_size (int): target image size.
1151
- das_anchor_scales (list[float]): a list of anchor scales in data
1152
- anchor smapling.
1153
- min_size (float): minimum size of sampled bbox.
1154
- avoid_no_bbox (bool): whether to to avoid the
1155
- situation where the box does not appear.
1156
- """
1157
- super(CropWithDataAchorSampling, self).__init__()
1158
- self.anchor_sampler = anchor_sampler
1159
- self.batch_sampler = batch_sampler
1160
- self.target_size = target_size
1161
- self.sampling_prob = sampling_prob
1162
- self.min_size = min_size
1163
- self.avoid_no_bbox = avoid_no_bbox
1164
- self.das_anchor_scales = np.array(das_anchor_scales)
1165
-
1166
- def apply(self, sample, context):
1167
- """
1168
- Crop the image and modify bounding box.
1169
- Operators:
1170
- 1. Scale the image width and height.
1171
- 2. Crop the image according to a radom sample.
1172
- 3. Rescale the bounding box.
1173
- 4. Determine if the new bbox is satisfied in the new image.
1174
- Returns:
1175
- sample: the image, bounding box are replaced.
1176
- """
1177
- assert 'image' in sample, "image data not found"
1178
- im = sample['image']
1179
- gt_bbox = sample['gt_bbox']
1180
- gt_class = sample['gt_class']
1181
- image_height, image_width = im.shape[:2]
1182
- gt_bbox[:, 0] /= image_width
1183
- gt_bbox[:, 1] /= image_height
1184
- gt_bbox[:, 2] /= image_width
1185
- gt_bbox[:, 3] /= image_height
1186
- gt_score = None
1187
- if 'gt_score' in sample:
1188
- gt_score = sample['gt_score']
1189
- sampled_bbox = []
1190
- gt_bbox = gt_bbox.tolist()
1191
-
1192
- prob = np.random.uniform(0., 1.)
1193
- if prob > self.sampling_prob: # anchor sampling
1194
- assert self.anchor_sampler
1195
- for sampler in self.anchor_sampler:
1196
- found = 0
1197
- for i in range(sampler[1]):
1198
- if found >= sampler[0]:
1199
- break
1200
- sample_bbox = data_anchor_sampling(
1201
- gt_bbox, image_width, image_height,
1202
- self.das_anchor_scales, self.target_size)
1203
- if sample_bbox == 0:
1204
- break
1205
- if satisfy_sample_constraint_coverage(sampler, sample_bbox,
1206
- gt_bbox):
1207
- sampled_bbox.append(sample_bbox)
1208
- found = found + 1
1209
- im = np.array(im)
1210
- while sampled_bbox:
1211
- idx = int(np.random.uniform(0, len(sampled_bbox)))
1212
- sample_bbox = sampled_bbox.pop(idx)
1213
-
1214
- if 'gt_keypoint' in sample.keys():
1215
- keypoints = (sample['gt_keypoint'],
1216
- sample['keypoint_ignore'])
1217
- crop_bbox, crop_class, crop_score, gt_keypoints = \
1218
- filter_and_process(sample_bbox, gt_bbox, gt_class,
1219
- scores=gt_score,
1220
- keypoints=keypoints)
1221
- else:
1222
- crop_bbox, crop_class, crop_score = filter_and_process(
1223
- sample_bbox, gt_bbox, gt_class, scores=gt_score)
1224
- crop_bbox, crop_class, crop_score = bbox_area_sampling(
1225
- crop_bbox, crop_class, crop_score, self.target_size,
1226
- self.min_size)
1227
-
1228
- if self.avoid_no_bbox:
1229
- if len(crop_bbox) < 1:
1230
- continue
1231
- im = crop_image_sampling(im, sample_bbox, image_width,
1232
- image_height, self.target_size)
1233
- height, width = im.shape[:2]
1234
- crop_bbox[:, 0] *= width
1235
- crop_bbox[:, 1] *= height
1236
- crop_bbox[:, 2] *= width
1237
- crop_bbox[:, 3] *= height
1238
- sample['image'] = im
1239
- sample['gt_bbox'] = crop_bbox
1240
- sample['gt_class'] = crop_class
1241
- if 'gt_score' in sample:
1242
- sample['gt_score'] = crop_score
1243
- if 'gt_keypoint' in sample.keys():
1244
- sample['gt_keypoint'] = gt_keypoints[0]
1245
- sample['keypoint_ignore'] = gt_keypoints[1]
1246
- return sample
1247
- return sample
1248
-
1249
- else:
1250
- for sampler in self.batch_sampler:
1251
- found = 0
1252
- for i in range(sampler[1]):
1253
- if found >= sampler[0]:
1254
- break
1255
- sample_bbox = generate_sample_bbox_square(
1256
- sampler, image_width, image_height)
1257
- if satisfy_sample_constraint_coverage(sampler, sample_bbox,
1258
- gt_bbox):
1259
- sampled_bbox.append(sample_bbox)
1260
- found = found + 1
1261
- im = np.array(im)
1262
- while sampled_bbox:
1263
- idx = int(np.random.uniform(0, len(sampled_bbox)))
1264
- sample_bbox = sampled_bbox.pop(idx)
1265
- sample_bbox = clip_bbox(sample_bbox)
1266
-
1267
- if 'gt_keypoint' in sample.keys():
1268
- keypoints = (sample['gt_keypoint'],
1269
- sample['keypoint_ignore'])
1270
- crop_bbox, crop_class, crop_score, gt_keypoints = \
1271
- filter_and_process(sample_bbox, gt_bbox, gt_class,
1272
- scores=gt_score,
1273
- keypoints=keypoints)
1274
- else:
1275
- crop_bbox, crop_class, crop_score = filter_and_process(
1276
- sample_bbox, gt_bbox, gt_class, scores=gt_score)
1277
- # sampling bbox according the bbox area
1278
- crop_bbox, crop_class, crop_score = bbox_area_sampling(
1279
- crop_bbox, crop_class, crop_score, self.target_size,
1280
- self.min_size)
1281
-
1282
- if self.avoid_no_bbox:
1283
- if len(crop_bbox) < 1:
1284
- continue
1285
- xmin = int(sample_bbox[0] * image_width)
1286
- xmax = int(sample_bbox[2] * image_width)
1287
- ymin = int(sample_bbox[1] * image_height)
1288
- ymax = int(sample_bbox[3] * image_height)
1289
- im = im[ymin:ymax, xmin:xmax]
1290
- height, width = im.shape[:2]
1291
- crop_bbox[:, 0] *= width
1292
- crop_bbox[:, 1] *= height
1293
- crop_bbox[:, 2] *= width
1294
- crop_bbox[:, 3] *= height
1295
- sample['image'] = im
1296
- sample['gt_bbox'] = crop_bbox
1297
- sample['gt_class'] = crop_class
1298
- if 'gt_score' in sample:
1299
- sample['gt_score'] = crop_score
1300
- if 'gt_keypoint' in sample.keys():
1301
- sample['gt_keypoint'] = gt_keypoints[0]
1302
- sample['keypoint_ignore'] = gt_keypoints[1]
1303
- return sample
1304
- return sample
1305
-
1306
-
1307
- @register_op
1308
- class RandomCrop(BaseOperator):
1309
- """Random crop image and bboxes.
1310
- Args:
1311
- aspect_ratio (list): aspect ratio of cropped region.
1312
- in [min, max] format.
1313
- thresholds (list): iou thresholds for decide a valid bbox crop.
1314
- scaling (list): ratio between a cropped region and the original image.
1315
- in [min, max] format.
1316
- num_attempts (int): number of tries before giving up.
1317
- allow_no_crop (bool): allow return without actually cropping them.
1318
- cover_all_box (bool): ensure all bboxes are covered in the final crop.
1319
- is_mask_crop(bool): whether crop the segmentation.
1320
- """
1321
-
1322
- def __init__(self,
1323
- aspect_ratio=[.5, 2.],
1324
- thresholds=[.0, .1, .3, .5, .7, .9],
1325
- scaling=[.3, 1.],
1326
- num_attempts=50,
1327
- allow_no_crop=True,
1328
- cover_all_box=False,
1329
- is_mask_crop=False):
1330
- super(RandomCrop, self).__init__()
1331
- self.aspect_ratio = aspect_ratio
1332
- self.thresholds = thresholds
1333
- self.scaling = scaling
1334
- self.num_attempts = num_attempts
1335
- self.allow_no_crop = allow_no_crop
1336
- self.cover_all_box = cover_all_box
1337
- self.is_mask_crop = is_mask_crop
1338
-
1339
- def crop_segms(self, segms, valid_ids, crop, height, width):
1340
- def _crop_poly(segm, crop):
1341
- xmin, ymin, xmax, ymax = crop
1342
- crop_coord = [xmin, ymin, xmin, ymax, xmax, ymax, xmax, ymin]
1343
- crop_p = np.array(crop_coord).reshape(4, 2)
1344
- crop_p = Polygon(crop_p)
1345
-
1346
- crop_segm = list()
1347
- for poly in segm:
1348
- poly = np.array(poly).reshape(len(poly) // 2, 2)
1349
- polygon = Polygon(poly)
1350
- if not polygon.is_valid:
1351
- exterior = polygon.exterior
1352
- multi_lines = exterior.intersection(exterior)
1353
- polygons = shapely.ops.polygonize(multi_lines)
1354
- polygon = MultiPolygon(polygons)
1355
- multi_polygon = list()
1356
- if isinstance(polygon, MultiPolygon):
1357
- multi_polygon = copy.deepcopy(polygon)
1358
- else:
1359
- multi_polygon.append(copy.deepcopy(polygon))
1360
- for per_polygon in multi_polygon:
1361
- inter = per_polygon.intersection(crop_p)
1362
- if not inter:
1363
- continue
1364
- if isinstance(inter, (MultiPolygon, GeometryCollection)):
1365
- for part in inter:
1366
- if not isinstance(part, Polygon):
1367
- continue
1368
- part = np.squeeze(
1369
- np.array(part.exterior.coords[:-1]).reshape(
1370
- 1, -1))
1371
- part[0::2] -= xmin
1372
- part[1::2] -= ymin
1373
- crop_segm.append(part.tolist())
1374
- elif isinstance(inter, Polygon):
1375
- crop_poly = np.squeeze(
1376
- np.array(inter.exterior.coords[:-1]).reshape(1,
1377
- -1))
1378
- crop_poly[0::2] -= xmin
1379
- crop_poly[1::2] -= ymin
1380
- crop_segm.append(crop_poly.tolist())
1381
- else:
1382
- continue
1383
- return crop_segm
1384
-
1385
- def _crop_rle(rle, crop, height, width):
1386
- if 'counts' in rle and type(rle['counts']) == list:
1387
- rle = mask_util.frPyObjects(rle, height, width)
1388
- mask = mask_util.decode(rle)
1389
- mask = mask[crop[1]:crop[3], crop[0]:crop[2]]
1390
- rle = mask_util.encode(np.array(mask, order='F', dtype=np.uint8))
1391
- return rle
1392
-
1393
- crop_segms = []
1394
- for id in valid_ids:
1395
- segm = segms[id]
1396
- if is_poly(segm):
1397
- import copy
1398
- import shapely.ops
1399
- from shapely.geometry import Polygon, MultiPolygon, GeometryCollection
1400
- logging.getLogger("shapely").setLevel(logging.WARNING)
1401
- # Polygon format
1402
- crop_segms.append(_crop_poly(segm, crop))
1403
- else:
1404
- # RLE format
1405
- import pycocotools.mask as mask_util
1406
- crop_segms.append(_crop_rle(segm, crop, height, width))
1407
- return crop_segms
1408
-
1409
- def apply(self, sample, context=None):
1410
- if 'gt_bbox' in sample and len(sample['gt_bbox']) == 0:
1411
- return sample
1412
-
1413
- h, w = sample['image'].shape[:2]
1414
- gt_bbox = sample['gt_bbox']
1415
-
1416
- # NOTE Original method attempts to generate one candidate for each
1417
- # threshold then randomly sample one from the resulting list.
1418
- # Here a short circuit approach is taken, i.e., randomly choose a
1419
- # threshold and attempt to find a valid crop, and simply return the
1420
- # first one found.
1421
- # The probability is not exactly the same, kinda resembling the
1422
- # "Monty Hall" problem. Actually carrying out the attempts will affect
1423
- # observability (just like opening doors in the "Monty Hall" game).
1424
- thresholds = list(self.thresholds)
1425
- if self.allow_no_crop:
1426
- thresholds.append('no_crop')
1427
- np.random.shuffle(thresholds)
1428
-
1429
- for thresh in thresholds:
1430
- if thresh == 'no_crop':
1431
- return sample
1432
-
1433
- found = False
1434
- for i in range(self.num_attempts):
1435
- scale = np.random.uniform(*self.scaling)
1436
- if self.aspect_ratio is not None:
1437
- min_ar, max_ar = self.aspect_ratio
1438
- aspect_ratio = np.random.uniform(
1439
- max(min_ar, scale**2), min(max_ar, scale**-2))
1440
- h_scale = scale / np.sqrt(aspect_ratio)
1441
- w_scale = scale * np.sqrt(aspect_ratio)
1442
- else:
1443
- h_scale = np.random.uniform(*self.scaling)
1444
- w_scale = np.random.uniform(*self.scaling)
1445
- crop_h = h * h_scale
1446
- crop_w = w * w_scale
1447
- if self.aspect_ratio is None:
1448
- if crop_h / crop_w < 0.5 or crop_h / crop_w > 2.0:
1449
- continue
1450
-
1451
- crop_h = int(crop_h)
1452
- crop_w = int(crop_w)
1453
- crop_y = np.random.randint(0, h - crop_h)
1454
- crop_x = np.random.randint(0, w - crop_w)
1455
- crop_box = [crop_x, crop_y, crop_x + crop_w, crop_y + crop_h]
1456
- iou = self._iou_matrix(
1457
- gt_bbox, np.array(
1458
- [crop_box], dtype=np.float32))
1459
- if iou.max() < thresh:
1460
- continue
1461
-
1462
- if self.cover_all_box and iou.min() < thresh:
1463
- continue
1464
-
1465
- cropped_box, valid_ids = self._crop_box_with_center_constraint(
1466
- gt_bbox, np.array(
1467
- crop_box, dtype=np.float32))
1468
- if valid_ids.size > 0:
1469
- found = True
1470
- break
1471
-
1472
- if found:
1473
- if self.is_mask_crop and 'gt_poly' in sample and len(sample[
1474
- 'gt_poly']) > 0:
1475
- crop_polys = self.crop_segms(
1476
- sample['gt_poly'],
1477
- valid_ids,
1478
- np.array(
1479
- crop_box, dtype=np.int64),
1480
- h,
1481
- w)
1482
- if [] in crop_polys:
1483
- delete_id = list()
1484
- valid_polys = list()
1485
- for id, crop_poly in enumerate(crop_polys):
1486
- if crop_poly == []:
1487
- delete_id.append(id)
1488
- else:
1489
- valid_polys.append(crop_poly)
1490
- valid_ids = np.delete(valid_ids, delete_id)
1491
- if len(valid_polys) == 0:
1492
- return sample
1493
- sample['gt_poly'] = valid_polys
1494
- else:
1495
- sample['gt_poly'] = crop_polys
1496
-
1497
- if 'gt_segm' in sample:
1498
- sample['gt_segm'] = self._crop_segm(sample['gt_segm'],
1499
- crop_box)
1500
- sample['gt_segm'] = np.take(
1501
- sample['gt_segm'], valid_ids, axis=0)
1502
-
1503
- sample['image'] = self._crop_image(sample['image'], crop_box)
1504
- sample['gt_bbox'] = np.take(cropped_box, valid_ids, axis=0)
1505
- sample['gt_class'] = np.take(
1506
- sample['gt_class'], valid_ids, axis=0)
1507
- if 'gt_score' in sample:
1508
- sample['gt_score'] = np.take(
1509
- sample['gt_score'], valid_ids, axis=0)
1510
-
1511
- if 'is_crowd' in sample:
1512
- sample['is_crowd'] = np.take(
1513
- sample['is_crowd'], valid_ids, axis=0)
1514
- return sample
1515
-
1516
- return sample
1517
-
1518
- def _iou_matrix(self, a, b):
1519
- tl_i = np.maximum(a[:, np.newaxis, :2], b[:, :2])
1520
- br_i = np.minimum(a[:, np.newaxis, 2:], b[:, 2:])
1521
-
1522
- area_i = np.prod(br_i - tl_i, axis=2) * (tl_i < br_i).all(axis=2)
1523
- area_a = np.prod(a[:, 2:] - a[:, :2], axis=1)
1524
- area_b = np.prod(b[:, 2:] - b[:, :2], axis=1)
1525
- area_o = (area_a[:, np.newaxis] + area_b - area_i)
1526
- return area_i / (area_o + 1e-10)
1527
-
1528
- def _crop_box_with_center_constraint(self, box, crop):
1529
- cropped_box = box.copy()
1530
-
1531
- cropped_box[:, :2] = np.maximum(box[:, :2], crop[:2])
1532
- cropped_box[:, 2:] = np.minimum(box[:, 2:], crop[2:])
1533
- cropped_box[:, :2] -= crop[:2]
1534
- cropped_box[:, 2:] -= crop[:2]
1535
-
1536
- centers = (box[:, :2] + box[:, 2:]) / 2
1537
- valid = np.logical_and(crop[:2] <= centers,
1538
- centers < crop[2:]).all(axis=1)
1539
- valid = np.logical_and(
1540
- valid, (cropped_box[:, :2] < cropped_box[:, 2:]).all(axis=1))
1541
-
1542
- return cropped_box, np.where(valid)[0]
1543
-
1544
- def _crop_image(self, img, crop):
1545
- x1, y1, x2, y2 = crop
1546
- return img[y1:y2, x1:x2, :]
1547
-
1548
- def _crop_segm(self, segm, crop):
1549
- x1, y1, x2, y2 = crop
1550
- return segm[:, y1:y2, x1:x2]
1551
-
1552
-
1553
- @register_op
1554
- class RandomScaledCrop(BaseOperator):
1555
- """Resize image and bbox based on long side (with optional random scaling),
1556
- then crop or pad image to target size.
1557
- Args:
1558
- target_dim (int): target size.
1559
- scale_range (list): random scale range.
1560
- interp (int): interpolation method, default to `cv2.INTER_LINEAR`.
1561
- """
1562
-
1563
- def __init__(self,
1564
- target_dim=512,
1565
- scale_range=[.1, 2.],
1566
- interp=cv2.INTER_LINEAR):
1567
- super(RandomScaledCrop, self).__init__()
1568
- self.target_dim = target_dim
1569
- self.scale_range = scale_range
1570
- self.interp = interp
1571
-
1572
- def apply(self, sample, context=None):
1573
- img = sample['image']
1574
- h, w = img.shape[:2]
1575
- random_scale = np.random.uniform(*self.scale_range)
1576
- dim = self.target_dim
1577
- random_dim = int(dim * random_scale)
1578
- dim_max = max(h, w)
1579
- scale = random_dim / dim_max
1580
- resize_w = w * scale
1581
- resize_h = h * scale
1582
- offset_x = int(max(0, np.random.uniform(0., resize_w - dim)))
1583
- offset_y = int(max(0, np.random.uniform(0., resize_h - dim)))
1584
-
1585
- img = cv2.resize(img, (resize_w, resize_h), interpolation=self.interp)
1586
- img = np.array(img)
1587
- canvas = np.zeros((dim, dim, 3), dtype=img.dtype)
1588
- canvas[:min(dim, resize_h), :min(dim, resize_w), :] = img[
1589
- offset_y:offset_y + dim, offset_x:offset_x + dim, :]
1590
- sample['image'] = canvas
1591
- sample['im_shape'] = np.asarray([resize_h, resize_w], dtype=np.float32)
1592
- scale_factor = sample['sacle_factor']
1593
- sample['scale_factor'] = np.asarray(
1594
- [scale_factor[0] * scale, scale_factor[1] * scale],
1595
- dtype=np.float32)
1596
-
1597
- if 'gt_bbox' in sample and len(sample['gt_bbox']) > 0:
1598
- scale_array = np.array([scale, scale] * 2, dtype=np.float32)
1599
- shift_array = np.array([offset_x, offset_y] * 2, dtype=np.float32)
1600
- boxes = sample['gt_bbox'] * scale_array - shift_array
1601
- boxes = np.clip(boxes, 0, dim - 1)
1602
- # filter boxes with no area
1603
- area = np.prod(boxes[..., 2:] - boxes[..., :2], axis=1)
1604
- valid = (area > 1.).nonzero()[0]
1605
- sample['gt_bbox'] = boxes[valid]
1606
- sample['gt_class'] = sample['gt_class'][valid]
1607
-
1608
- return sample
1609
-
1610
-
1611
- @register_op
1612
- class Cutmix(BaseOperator):
1613
- def __init__(self, alpha=1.5, beta=1.5):
1614
- """
1615
- CutMix: Regularization Strategy to Train Strong Classifiers with Localizable Features, see https://arxiv.org/abs/1905.04899
1616
- Cutmix image and gt_bbbox/gt_score
1617
- Args:
1618
- alpha (float): alpha parameter of beta distribute
1619
- beta (float): beta parameter of beta distribute
1620
- """
1621
- super(Cutmix, self).__init__()
1622
- self.alpha = alpha
1623
- self.beta = beta
1624
- if self.alpha <= 0.0:
1625
- raise ValueError("alpha shold be positive in {}".format(self))
1626
- if self.beta <= 0.0:
1627
- raise ValueError("beta shold be positive in {}".format(self))
1628
-
1629
- def apply_image(self, img1, img2, factor):
1630
- """ _rand_bbox """
1631
- h = max(img1.shape[0], img2.shape[0])
1632
- w = max(img1.shape[1], img2.shape[1])
1633
- cut_rat = np.sqrt(1. - factor)
1634
-
1635
- cut_w = np.int32(w * cut_rat)
1636
- cut_h = np.int32(h * cut_rat)
1637
-
1638
- # uniform
1639
- cx = np.random.randint(w)
1640
- cy = np.random.randint(h)
1641
-
1642
- bbx1 = np.clip(cx - cut_w // 2, 0, w - 1)
1643
- bby1 = np.clip(cy - cut_h // 2, 0, h - 1)
1644
- bbx2 = np.clip(cx + cut_w // 2, 0, w - 1)
1645
- bby2 = np.clip(cy + cut_h // 2, 0, h - 1)
1646
-
1647
- img_1_pad = np.zeros((h, w, img1.shape[2]), 'float32')
1648
- img_1_pad[:img1.shape[0], :img1.shape[1], :] = \
1649
- img1.astype('float32')
1650
- img_2_pad = np.zeros((h, w, img2.shape[2]), 'float32')
1651
- img_2_pad[:img2.shape[0], :img2.shape[1], :] = \
1652
- img2.astype('float32')
1653
- img_1_pad[bby1:bby2, bbx1:bbx2, :] = img_2_pad[bby1:bby2, bbx1:bbx2, :]
1654
- return img_1_pad
1655
-
1656
- def __call__(self, sample, context=None):
1657
- if not isinstance(sample, Sequence):
1658
- return sample
1659
-
1660
- assert len(sample) == 2, 'cutmix need two samples'
1661
-
1662
- factor = np.random.beta(self.alpha, self.beta)
1663
- factor = max(0.0, min(1.0, factor))
1664
- if factor >= 1.0:
1665
- return sample[0]
1666
- if factor <= 0.0:
1667
- return sample[1]
1668
- img1 = sample[0]['image']
1669
- img2 = sample[1]['image']
1670
- img = self.apply_image(img1, img2, factor)
1671
- gt_bbox1 = sample[0]['gt_bbox']
1672
- gt_bbox2 = sample[1]['gt_bbox']
1673
- gt_bbox = np.concatenate((gt_bbox1, gt_bbox2), axis=0)
1674
- gt_class1 = sample[0]['gt_class']
1675
- gt_class2 = sample[1]['gt_class']
1676
- gt_class = np.concatenate((gt_class1, gt_class2), axis=0)
1677
- gt_score1 = np.ones_like(sample[0]['gt_class'])
1678
- gt_score2 = np.ones_like(sample[1]['gt_class'])
1679
- gt_score = np.concatenate(
1680
- (gt_score1 * factor, gt_score2 * (1. - factor)), axis=0)
1681
- result = copy.deepcopy(sample[0])
1682
- result['image'] = img
1683
- result['gt_bbox'] = gt_bbox
1684
- result['gt_score'] = gt_score
1685
- result['gt_class'] = gt_class
1686
- if 'is_crowd' in sample[0]:
1687
- is_crowd1 = sample[0]['is_crowd']
1688
- is_crowd2 = sample[1]['is_crowd']
1689
- is_crowd = np.concatenate((is_crowd1, is_crowd2), axis=0)
1690
- result['is_crowd'] = is_crowd
1691
- if 'difficult' in sample[0]:
1692
- is_difficult1 = sample[0]['difficult']
1693
- is_difficult2 = sample[1]['difficult']
1694
- is_difficult = np.concatenate(
1695
- (is_difficult1, is_difficult2), axis=0)
1696
- result['difficult'] = is_difficult
1697
- return result
1698
-
1699
-
1700
- @register_op
1701
- class Mixup(BaseOperator):
1702
- def __init__(self, alpha=1.5, beta=1.5):
1703
- """ Mixup image and gt_bbbox/gt_score
1704
- Args:
1705
- alpha (float): alpha parameter of beta distribute
1706
- beta (float): beta parameter of beta distribute
1707
- """
1708
- super(Mixup, self).__init__()
1709
- self.alpha = alpha
1710
- self.beta = beta
1711
- if self.alpha <= 0.0:
1712
- raise ValueError("alpha shold be positive in {}".format(self))
1713
- if self.beta <= 0.0:
1714
- raise ValueError("beta shold be positive in {}".format(self))
1715
-
1716
- def apply_image(self, img1, img2, factor):
1717
- h = max(img1.shape[0], img2.shape[0])
1718
- w = max(img1.shape[1], img2.shape[1])
1719
- img = np.zeros((h, w, img1.shape[2]), 'float32')
1720
- img[:img1.shape[0], :img1.shape[1], :] = \
1721
- img1.astype('float32') * factor
1722
- img[:img2.shape[0], :img2.shape[1], :] += \
1723
- img2.astype('float32') * (1.0 - factor)
1724
- return img.astype('uint8')
1725
-
1726
- def __call__(self, sample, context=None):
1727
- if not isinstance(sample, Sequence):
1728
- return sample
1729
-
1730
- assert len(sample) == 2, 'mixup need two samples'
1731
-
1732
- factor = np.random.beta(self.alpha, self.beta)
1733
- factor = max(0.0, min(1.0, factor))
1734
- if factor >= 1.0:
1735
- return sample[0]
1736
- if factor <= 0.0:
1737
- return sample[1]
1738
- im = self.apply_image(sample[0]['image'], sample[1]['image'], factor)
1739
- result = copy.deepcopy(sample[0])
1740
- result['image'] = im
1741
- # apply bbox and score
1742
- if 'gt_bbox' in sample[0]:
1743
- gt_bbox1 = sample[0]['gt_bbox']
1744
- gt_bbox2 = sample[1]['gt_bbox']
1745
- gt_bbox = np.concatenate((gt_bbox1, gt_bbox2), axis=0)
1746
- result['gt_bbox'] = gt_bbox
1747
- if 'gt_class' in sample[0]:
1748
- gt_class1 = sample[0]['gt_class']
1749
- gt_class2 = sample[1]['gt_class']
1750
- gt_class = np.concatenate((gt_class1, gt_class2), axis=0)
1751
- result['gt_class'] = gt_class
1752
-
1753
- gt_score1 = np.ones_like(sample[0]['gt_class'])
1754
- gt_score2 = np.ones_like(sample[1]['gt_class'])
1755
- gt_score = np.concatenate(
1756
- (gt_score1 * factor, gt_score2 * (1. - factor)), axis=0)
1757
- result['gt_score'] = gt_score
1758
- if 'is_crowd' in sample[0]:
1759
- is_crowd1 = sample[0]['is_crowd']
1760
- is_crowd2 = sample[1]['is_crowd']
1761
- is_crowd = np.concatenate((is_crowd1, is_crowd2), axis=0)
1762
- result['is_crowd'] = is_crowd
1763
- if 'difficult' in sample[0]:
1764
- is_difficult1 = sample[0]['difficult']
1765
- is_difficult2 = sample[1]['difficult']
1766
- is_difficult = np.concatenate(
1767
- (is_difficult1, is_difficult2), axis=0)
1768
- result['difficult'] = is_difficult
1769
-
1770
- if 'gt_ide' in sample[0]:
1771
- gt_ide1 = sample[0]['gt_ide']
1772
- gt_ide2 = sample[1]['gt_ide']
1773
- gt_ide = np.concatenate((gt_ide1, gt_ide2), axis=0)
1774
- result['gt_ide'] = gt_ide
1775
- return result
1776
-
1777
-
1778
- @register_op
1779
- class NormalizeBox(BaseOperator):
1780
- """Transform the bounding box's coornidates to [0,1]."""
1781
-
1782
- def __init__(self):
1783
- super(NormalizeBox, self).__init__()
1784
-
1785
- def apply(self, sample, context):
1786
- im = sample['image']
1787
- gt_bbox = sample['gt_bbox']
1788
- height, width, _ = im.shape
1789
- for i in range(gt_bbox.shape[0]):
1790
- gt_bbox[i][0] = gt_bbox[i][0] / width
1791
- gt_bbox[i][1] = gt_bbox[i][1] / height
1792
- gt_bbox[i][2] = gt_bbox[i][2] / width
1793
- gt_bbox[i][3] = gt_bbox[i][3] / height
1794
- sample['gt_bbox'] = gt_bbox
1795
-
1796
- if 'gt_keypoint' in sample.keys():
1797
- gt_keypoint = sample['gt_keypoint']
1798
-
1799
- for i in range(gt_keypoint.shape[1]):
1800
- if i % 2:
1801
- gt_keypoint[:, i] = gt_keypoint[:, i] / height
1802
- else:
1803
- gt_keypoint[:, i] = gt_keypoint[:, i] / width
1804
- sample['gt_keypoint'] = gt_keypoint
1805
-
1806
- return sample
1807
-
1808
-
1809
- @register_op
1810
- class BboxXYXY2XYWH(BaseOperator):
1811
- """
1812
- Convert bbox XYXY format to XYWH format.
1813
- """
1814
-
1815
- def __init__(self):
1816
- super(BboxXYXY2XYWH, self).__init__()
1817
-
1818
- def apply(self, sample, context=None):
1819
- assert 'gt_bbox' in sample
1820
- bbox = sample['gt_bbox']
1821
- bbox[:, 2:4] = bbox[:, 2:4] - bbox[:, :2]
1822
- bbox[:, :2] = bbox[:, :2] + bbox[:, 2:4] / 2.
1823
- sample['gt_bbox'] = bbox
1824
- return sample
1825
-
1826
-
1827
- @register_op
1828
- class PadBox(BaseOperator):
1829
- def __init__(self, num_max_boxes=50):
1830
- """
1831
- Pad zeros to bboxes if number of bboxes is less than num_max_boxes.
1832
- Args:
1833
- num_max_boxes (int): the max number of bboxes
1834
- """
1835
- self.num_max_boxes = num_max_boxes
1836
- super(PadBox, self).__init__()
1837
-
1838
- def apply(self, sample, context=None):
1839
- assert 'gt_bbox' in sample
1840
- bbox = sample['gt_bbox']
1841
- gt_num = min(self.num_max_boxes, len(bbox))
1842
- num_max = self.num_max_boxes
1843
- # fields = context['fields'] if context else []
1844
- pad_bbox = np.zeros((num_max, 4), dtype=np.float32)
1845
- if gt_num > 0:
1846
- pad_bbox[:gt_num, :] = bbox[:gt_num, :]
1847
- sample['gt_bbox'] = pad_bbox
1848
- if 'gt_class' in sample:
1849
- pad_class = np.zeros((num_max, ), dtype=np.int32)
1850
- if gt_num > 0:
1851
- pad_class[:gt_num] = sample['gt_class'][:gt_num, 0]
1852
- sample['gt_class'] = pad_class
1853
- if 'gt_score' in sample:
1854
- pad_score = np.zeros((num_max, ), dtype=np.float32)
1855
- if gt_num > 0:
1856
- pad_score[:gt_num] = sample['gt_score'][:gt_num, 0]
1857
- sample['gt_score'] = pad_score
1858
- # in training, for example in op ExpandImage,
1859
- # the bbox and gt_class is expandded, but the difficult is not,
1860
- # so, judging by it's length
1861
- if 'difficult' in sample:
1862
- pad_diff = np.zeros((num_max, ), dtype=np.int32)
1863
- if gt_num > 0:
1864
- pad_diff[:gt_num] = sample['difficult'][:gt_num, 0]
1865
- sample['difficult'] = pad_diff
1866
- if 'is_crowd' in sample:
1867
- pad_crowd = np.zeros((num_max, ), dtype=np.int32)
1868
- if gt_num > 0:
1869
- pad_crowd[:gt_num] = sample['is_crowd'][:gt_num, 0]
1870
- sample['is_crowd'] = pad_crowd
1871
- if 'gt_ide' in sample:
1872
- pad_ide = np.zeros((num_max, ), dtype=np.int32)
1873
- if gt_num > 0:
1874
- pad_ide[:gt_num] = sample['gt_ide'][:gt_num, 0]
1875
- sample['gt_ide'] = pad_ide
1876
- return sample
1877
-
1878
-
1879
- @register_op
1880
- class DebugVisibleImage(BaseOperator):
1881
- """
1882
- In debug mode, visualize images according to `gt_box`.
1883
- (Currently only supported when not cropping and flipping image.)
1884
- """
1885
-
1886
- def __init__(self, output_dir='output/debug', is_normalized=False):
1887
- super(DebugVisibleImage, self).__init__()
1888
- self.is_normalized = is_normalized
1889
- self.output_dir = output_dir
1890
- if not os.path.isdir(output_dir):
1891
- os.makedirs(output_dir)
1892
- if not isinstance(self.is_normalized, bool):
1893
- raise TypeError("{}: input type is invalid.".format(self))
1894
-
1895
- def apply(self, sample, context=None):
1896
- image = Image.fromarray(sample['image'].astype(np.uint8))
1897
- out_file_name = '{:012d}.jpg'.format(sample['im_id'][0])
1898
- width = sample['w']
1899
- height = sample['h']
1900
- gt_bbox = sample['gt_bbox']
1901
- gt_class = sample['gt_class']
1902
- draw = ImageDraw.Draw(image)
1903
- for i in range(gt_bbox.shape[0]):
1904
- if self.is_normalized:
1905
- gt_bbox[i][0] = gt_bbox[i][0] * width
1906
- gt_bbox[i][1] = gt_bbox[i][1] * height
1907
- gt_bbox[i][2] = gt_bbox[i][2] * width
1908
- gt_bbox[i][3] = gt_bbox[i][3] * height
1909
-
1910
- xmin, ymin, xmax, ymax = gt_bbox[i]
1911
- draw.line(
1912
- [(xmin, ymin), (xmin, ymax), (xmax, ymax), (xmax, ymin),
1913
- (xmin, ymin)],
1914
- width=2,
1915
- fill='green')
1916
- # draw label
1917
- text = str(gt_class[i][0])
1918
- tw, th = draw.textsize(text)
1919
- draw.rectangle(
1920
- [(xmin + 1, ymin - th), (xmin + tw + 1, ymin)], fill='green')
1921
- draw.text((xmin + 1, ymin - th), text, fill=(255, 255, 255))
1922
-
1923
- if 'gt_keypoint' in sample.keys():
1924
- gt_keypoint = sample['gt_keypoint']
1925
- if self.is_normalized:
1926
- for i in range(gt_keypoint.shape[1]):
1927
- if i % 2:
1928
- gt_keypoint[:, i] = gt_keypoint[:, i] * height
1929
- else:
1930
- gt_keypoint[:, i] = gt_keypoint[:, i] * width
1931
- for i in range(gt_keypoint.shape[0]):
1932
- keypoint = gt_keypoint[i]
1933
- for j in range(int(keypoint.shape[0] / 2)):
1934
- x1 = round(keypoint[2 * j]).astype(np.int32)
1935
- y1 = round(keypoint[2 * j + 1]).astype(np.int32)
1936
- draw.ellipse(
1937
- (x1, y1, x1 + 5, y1 + 5),
1938
- fill='green',
1939
- outline='green')
1940
- save_path = os.path.join(self.output_dir, out_file_name)
1941
- image.save(save_path, quality=95)
1942
- return sample
1943
-
1944
-
1945
- @register_op
1946
- class Pad(BaseOperator):
1947
- def __init__(self,
1948
- size=None,
1949
- size_divisor=32,
1950
- pad_mode=0,
1951
- offsets=None,
1952
- fill_value=(127.5, 127.5, 127.5)):
1953
- """
1954
- Pad image to a specified size or multiple of size_divisor.
1955
- Args:
1956
- size (int, Sequence): image target size, if None, pad to multiple of size_divisor, default None
1957
- size_divisor (int): size divisor, default 32
1958
- pad_mode (int): pad mode, currently only supports four modes [-1, 0, 1, 2]. if -1, use specified offsets
1959
- if 0, only pad to right and bottom. if 1, pad according to center. if 2, only pad left and top
1960
- offsets (list): [offset_x, offset_y], specify offset while padding, only supported pad_mode=-1
1961
- fill_value (bool): rgb value of pad area, default (127.5, 127.5, 127.5)
1962
- """
1963
- super(Pad, self).__init__()
1964
-
1965
- if not isinstance(size, (int, Sequence)):
1966
- raise TypeError(
1967
- "Type of target_size is invalid when random_size is True. \
1968
- Must be List, now is {}".format(type(size)))
1969
-
1970
- if isinstance(size, int):
1971
- size = [size, size]
1972
-
1973
- assert pad_mode in [
1974
- -1, 0, 1, 2
1975
- ], 'currently only supports four modes [-1, 0, 1, 2]'
1976
- if pad_mode == -1:
1977
- assert offsets, 'if pad_mode is -1, offsets should not be None'
1978
-
1979
- self.size = size
1980
- self.size_divisor = size_divisor
1981
- self.pad_mode = pad_mode
1982
- self.fill_value = fill_value
1983
- self.offsets = offsets
1984
-
1985
- def apply_segm(self, segms, offsets, im_size, size):
1986
- def _expand_poly(poly, x, y):
1987
- expanded_poly = np.array(poly)
1988
- expanded_poly[0::2] += x
1989
- expanded_poly[1::2] += y
1990
- return expanded_poly.tolist()
1991
-
1992
- def _expand_rle(rle, x, y, height, width, h, w):
1993
- if 'counts' in rle and type(rle['counts']) == list:
1994
- rle = mask_util.frPyObjects(rle, height, width)
1995
- mask = mask_util.decode(rle)
1996
- expanded_mask = np.full((h, w), 0).astype(mask.dtype)
1997
- expanded_mask[y:y + height, x:x + width] = mask
1998
- rle = mask_util.encode(
1999
- np.array(
2000
- expanded_mask, order='F', dtype=np.uint8))
2001
- return rle
2002
-
2003
- x, y = offsets
2004
- height, width = im_size
2005
- h, w = size
2006
- expanded_segms = []
2007
- for segm in segms:
2008
- if is_poly(segm):
2009
- # Polygon format
2010
- expanded_segms.append(
2011
- [_expand_poly(poly, x, y) for poly in segm])
2012
- else:
2013
- # RLE format
2014
- import pycocotools.mask as mask_util
2015
- expanded_segms.append(
2016
- _expand_rle(segm, x, y, height, width, h, w))
2017
- return expanded_segms
2018
-
2019
- def apply_bbox(self, bbox, offsets):
2020
- return bbox + np.array(offsets * 2, dtype=np.float32)
2021
-
2022
- def apply_keypoint(self, keypoints, offsets):
2023
- n = len(keypoints[0]) // 2
2024
- return keypoints + np.array(offsets * n, dtype=np.float32)
2025
-
2026
- def apply_image(self, image, offsets, im_size, size):
2027
- x, y = offsets
2028
- im_h, im_w = im_size
2029
- h, w = size
2030
- canvas = np.ones((h, w, 3), dtype=np.float32)
2031
- canvas *= np.array(self.fill_value, dtype=np.float32)
2032
- canvas[y:y + im_h, x:x + im_w, :] = image.astype(np.float32)
2033
- return canvas
2034
-
2035
- def apply(self, sample, context=None):
2036
- im = sample['image']
2037
- im_h, im_w = im.shape[:2]
2038
- if self.size:
2039
- h, w = self.size
2040
- assert (
2041
- im_h < h and im_w < w
2042
- ), '(h, w) of target size should be greater than (im_h, im_w)'
2043
- else:
2044
- h = np.ceil(im_h / self.size_divisor) * self.size_divisor
2045
- w = np.ceil(im_w / self.size_divisor) * self.size_divisor
2046
-
2047
- if h == im_h and w == im_w:
2048
- return sample
2049
-
2050
- if self.pad_mode == -1:
2051
- offset_x, offset_y = self.offsets
2052
- elif self.pad_mode == 0:
2053
- offset_y, offset_x = 0, 0
2054
- elif self.pad_mode == 1:
2055
- offset_y, offset_x = (h - im_h) // 2, (w - im_w) // 2
2056
- else:
2057
- offset_y, offset_x = h - im_h, w - im_w
2058
-
2059
- offsets, im_size, size = [offset_x, offset_y], [im_h, im_w], [h, w]
2060
-
2061
- sample['image'] = self.apply_image(im, offsets, im_size, size)
2062
-
2063
- if self.pad_mode == 0:
2064
- return sample
2065
- if 'gt_bbox' in sample and len(sample['gt_bbox']) > 0:
2066
- sample['gt_bbox'] = self.apply_bbox(sample['gt_bbox'], offsets)
2067
-
2068
- if 'gt_poly' in sample and len(sample['gt_poly']) > 0:
2069
- sample['gt_poly'] = self.apply_segm(sample['gt_poly'], offsets,
2070
- im_size, size)
2071
-
2072
- if 'gt_keypoint' in sample and len(sample['gt_keypoint']) > 0:
2073
- sample['gt_keypoint'] = self.apply_keypoint(sample['gt_keypoint'],
2074
- offsets)
2075
-
2076
- return sample
2077
-
2078
-
2079
- @register_op
2080
- class Poly2Mask(BaseOperator):
2081
- """
2082
- gt poly to mask annotations
2083
- """
2084
-
2085
- def __init__(self):
2086
- super(Poly2Mask, self).__init__()
2087
- import pycocotools.mask as maskUtils
2088
- self.maskutils = maskUtils
2089
-
2090
- def _poly2mask(self, mask_ann, img_h, img_w):
2091
- if isinstance(mask_ann, list):
2092
- # polygon -- a single object might consist of multiple parts
2093
- # we merge all parts into one mask rle code
2094
- rles = self.maskutils.frPyObjects(mask_ann, img_h, img_w)
2095
- rle = self.maskutils.merge(rles)
2096
- elif isinstance(mask_ann['counts'], list):
2097
- # uncompressed RLE
2098
- rle = self.maskutils.frPyObjects(mask_ann, img_h, img_w)
2099
- else:
2100
- # rle
2101
- rle = mask_ann
2102
- mask = self.maskutils.decode(rle)
2103
- return mask
2104
-
2105
- def apply(self, sample, context=None):
2106
- assert 'gt_poly' in sample
2107
- im_h = sample['h']
2108
- im_w = sample['w']
2109
- masks = [
2110
- self._poly2mask(gt_poly, im_h, im_w)
2111
- for gt_poly in sample['gt_poly']
2112
- ]
2113
- sample['gt_segm'] = np.asarray(masks).astype(np.uint8)
2114
- return sample
2115
-
2116
-
2117
- @register_op
2118
- class Rbox2Poly(BaseOperator):
2119
- """
2120
- Convert rbbox format to poly format.
2121
- """
2122
-
2123
- def __init__(self):
2124
- super(Rbox2Poly, self).__init__()
2125
-
2126
- def apply(self, sample, context=None):
2127
- assert 'gt_rbox' in sample
2128
- assert sample['gt_rbox'].shape[1] == 5
2129
- rrects = sample['gt_rbox']
2130
- x_ctr = rrects[:, 0]
2131
- y_ctr = rrects[:, 1]
2132
- width = rrects[:, 2]
2133
- height = rrects[:, 3]
2134
- x1 = x_ctr - width / 2.0
2135
- y1 = y_ctr - height / 2.0
2136
- x2 = x_ctr + width / 2.0
2137
- y2 = y_ctr + height / 2.0
2138
- sample['gt_bbox'] = np.stack([x1, y1, x2, y2], axis=1)
2139
- polys = bbox_utils.rbox2poly_np(rrects)
2140
- sample['gt_rbox2poly'] = polys
2141
- return sample
2142
-
2143
-
2144
- @register_op
2145
- class AugmentHSV(BaseOperator):
2146
- def __init__(self, fraction=0.50, is_bgr=True):
2147
- """
2148
- Augment the SV channel of image data.
2149
- Args:
2150
- fraction (float): the fraction for augment. Default: 0.5.
2151
- is_bgr (bool): whether the image is BGR mode. Default: True.
2152
- """
2153
- super(AugmentHSV, self).__init__()
2154
- self.fraction = fraction
2155
- self.is_bgr = is_bgr
2156
-
2157
- def apply(self, sample, context=None):
2158
- img = sample['image']
2159
- if self.is_bgr:
2160
- img_hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
2161
- else:
2162
- img_hsv = cv2.cvtColor(img, cv2.COLOR_RGB2HSV)
2163
- S = img_hsv[:, :, 1].astype(np.float32)
2164
- V = img_hsv[:, :, 2].astype(np.float32)
2165
-
2166
- a = (random.random() * 2 - 1) * self.fraction + 1
2167
- S *= a
2168
- if a > 1:
2169
- np.clip(S, a_min=0, a_max=255, out=S)
2170
-
2171
- a = (random.random() * 2 - 1) * self.fraction + 1
2172
- V *= a
2173
- if a > 1:
2174
- np.clip(V, a_min=0, a_max=255, out=V)
2175
-
2176
- img_hsv[:, :, 1] = S.astype(np.uint8)
2177
- img_hsv[:, :, 2] = V.astype(np.uint8)
2178
- if self.is_bgr:
2179
- cv2.cvtColor(img_hsv, cv2.COLOR_HSV2BGR, dst=img)
2180
- else:
2181
- cv2.cvtColor(img_hsv, cv2.COLOR_HSV2RGB, dst=img)
2182
-
2183
- sample['image'] = img
2184
- return sample
2185
-
2186
-
2187
- @register_op
2188
- class Norm2PixelBbox(BaseOperator):
2189
- """
2190
- Transform the bounding box's coornidates which is in [0,1] to pixels.
2191
- """
2192
-
2193
- def __init__(self):
2194
- super(Norm2PixelBbox, self).__init__()
2195
-
2196
- def apply(self, sample, context=None):
2197
- assert 'gt_bbox' in sample
2198
- bbox = sample['gt_bbox']
2199
- height, width = sample['image'].shape[:2]
2200
- bbox[:, 0::2] = bbox[:, 0::2] * width
2201
- bbox[:, 1::2] = bbox[:, 1::2] * height
2202
- sample['gt_bbox'] = bbox
2203
- return sample
2204
-
2205
-
2206
- @register_op
2207
- class BboxCXCYWH2XYXY(BaseOperator):
2208
- """
2209
- Convert bbox CXCYWH format to XYXY format.
2210
- [center_x, center_y, width, height] -> [x0, y0, x1, y1]
2211
- """
2212
-
2213
- def __init__(self):
2214
- super(BboxCXCYWH2XYXY, self).__init__()
2215
-
2216
- def apply(self, sample, context=None):
2217
- assert 'gt_bbox' in sample
2218
- bbox0 = sample['gt_bbox']
2219
- bbox = bbox0.copy()
2220
-
2221
- bbox[:, :2] = bbox0[:, :2] - bbox0[:, 2:4] / 2.
2222
- bbox[:, 2:4] = bbox0[:, :2] + bbox0[:, 2:4] / 2.
2223
- sample['gt_bbox'] = bbox
2224
- return sample
2225
-
2226
-
2227
- @register_op
2228
- class RandomResizeCrop(BaseOperator):
2229
- """Random resize and crop image and bboxes.
2230
- Args:
2231
- resizes (list): resize image to one of resizes. if keep_ratio is True and mode is
2232
- 'long', resize the image's long side to the maximum of target_size, if keep_ratio is
2233
- True and mode is 'short', resize the image's short side to the minimum of target_size.
2234
- cropsizes (list): crop sizes after resize, [(min_crop_1, max_crop_1), ...]
2235
- mode (str): resize mode, `long` or `short`. Details see resizes.
2236
- prob (float): probability of this op.
2237
- keep_ratio (bool): whether keep_ratio or not, default true
2238
- interp (int): the interpolation method
2239
- thresholds (list): iou thresholds for decide a valid bbox crop.
2240
- num_attempts (int): number of tries before giving up.
2241
- allow_no_crop (bool): allow return without actually cropping them.
2242
- cover_all_box (bool): ensure all bboxes are covered in the final crop.
2243
- is_mask_crop(bool): whether crop the segmentation.
2244
- """
2245
-
2246
- def __init__(
2247
- self,
2248
- resizes,
2249
- cropsizes,
2250
- prob=0.5,
2251
- mode='short',
2252
- keep_ratio=True,
2253
- interp=cv2.INTER_LINEAR,
2254
- num_attempts=3,
2255
- cover_all_box=False,
2256
- allow_no_crop=False,
2257
- thresholds=[0.3, 0.5, 0.7],
2258
- is_mask_crop=False, ):
2259
- super(RandomResizeCrop, self).__init__()
2260
-
2261
- self.resizes = resizes
2262
- self.cropsizes = cropsizes
2263
- self.prob = prob
2264
- self.mode = mode
2265
-
2266
- self.resizer = Resize(0, keep_ratio=keep_ratio, interp=interp)
2267
- self.croper = RandomCrop(
2268
- num_attempts=num_attempts,
2269
- cover_all_box=cover_all_box,
2270
- thresholds=thresholds,
2271
- allow_no_crop=allow_no_crop,
2272
- is_mask_crop=is_mask_crop)
2273
-
2274
- def _format_size(self, size):
2275
- if isinstance(size, Integral):
2276
- size = (size, size)
2277
- return size
2278
-
2279
- def apply(self, sample, context=None):
2280
- if random.random() < self.prob:
2281
- _resize = self._format_size(random.choice(self.resizes))
2282
- _cropsize = self._format_size(random.choice(self.cropsizes))
2283
- sample = self._resize(
2284
- self.resizer,
2285
- sample,
2286
- size=_resize,
2287
- mode=self.mode,
2288
- context=context)
2289
- sample = self._random_crop(
2290
- self.croper, sample, size=_cropsize, context=context)
2291
- return sample
2292
-
2293
- @staticmethod
2294
- def _random_crop(croper, sample, size, context=None):
2295
- if 'gt_bbox' in sample and len(sample['gt_bbox']) == 0:
2296
- return sample
2297
-
2298
- self = croper
2299
- h, w = sample['image'].shape[:2]
2300
- gt_bbox = sample['gt_bbox']
2301
- cropsize = size
2302
- min_crop = min(cropsize)
2303
- max_crop = max(cropsize)
2304
-
2305
- thresholds = list(self.thresholds)
2306
- np.random.shuffle(thresholds)
2307
-
2308
- for thresh in thresholds:
2309
- found = False
2310
- for _ in range(self.num_attempts):
2311
-
2312
- crop_h = random.randint(min_crop, min(h, max_crop))
2313
- crop_w = random.randint(min_crop, min(w, max_crop))
2314
-
2315
- crop_y = random.randint(0, h - crop_h)
2316
- crop_x = random.randint(0, w - crop_w)
2317
-
2318
- crop_box = [crop_x, crop_y, crop_x + crop_w, crop_y + crop_h]
2319
- iou = self._iou_matrix(
2320
- gt_bbox, np.array(
2321
- [crop_box], dtype=np.float32))
2322
- if iou.max() < thresh:
2323
- continue
2324
-
2325
- if self.cover_all_box and iou.min() < thresh:
2326
- continue
2327
-
2328
- cropped_box, valid_ids = self._crop_box_with_center_constraint(
2329
- gt_bbox, np.array(
2330
- crop_box, dtype=np.float32))
2331
- if valid_ids.size > 0:
2332
- found = True
2333
- break
2334
-
2335
- if found:
2336
- if self.is_mask_crop and 'gt_poly' in sample and len(sample[
2337
- 'gt_poly']) > 0:
2338
- crop_polys = self.crop_segms(
2339
- sample['gt_poly'],
2340
- valid_ids,
2341
- np.array(
2342
- crop_box, dtype=np.int64),
2343
- h,
2344
- w)
2345
- if [] in crop_polys:
2346
- delete_id = list()
2347
- valid_polys = list()
2348
- for id, crop_poly in enumerate(crop_polys):
2349
- if crop_poly == []:
2350
- delete_id.append(id)
2351
- else:
2352
- valid_polys.append(crop_poly)
2353
- valid_ids = np.delete(valid_ids, delete_id)
2354
- if len(valid_polys) == 0:
2355
- return sample
2356
- sample['gt_poly'] = valid_polys
2357
- else:
2358
- sample['gt_poly'] = crop_polys
2359
-
2360
- if 'gt_segm' in sample:
2361
- sample['gt_segm'] = self._crop_segm(sample['gt_segm'],
2362
- crop_box)
2363
- sample['gt_segm'] = np.take(
2364
- sample['gt_segm'], valid_ids, axis=0)
2365
-
2366
- sample['image'] = self._crop_image(sample['image'], crop_box)
2367
- sample['gt_bbox'] = np.take(cropped_box, valid_ids, axis=0)
2368
- sample['gt_class'] = np.take(
2369
- sample['gt_class'], valid_ids, axis=0)
2370
- if 'gt_score' in sample:
2371
- sample['gt_score'] = np.take(
2372
- sample['gt_score'], valid_ids, axis=0)
2373
-
2374
- if 'is_crowd' in sample:
2375
- sample['is_crowd'] = np.take(
2376
- sample['is_crowd'], valid_ids, axis=0)
2377
- return sample
2378
-
2379
- return sample
2380
-
2381
- @staticmethod
2382
- def _resize(resizer, sample, size, mode='short', context=None):
2383
- self = resizer
2384
- im = sample['image']
2385
- target_size = size
2386
-
2387
- if not isinstance(im, np.ndarray):
2388
- raise TypeError("{}: image type is not numpy.".format(self))
2389
- if len(im.shape) != 3:
2390
- raise ImageError('{}: image is not 3-dimensional.'.format(self))
2391
-
2392
- # apply image
2393
- im_shape = im.shape
2394
- if self.keep_ratio:
2395
-
2396
- im_size_min = np.min(im_shape[0:2])
2397
- im_size_max = np.max(im_shape[0:2])
2398
-
2399
- target_size_min = np.min(target_size)
2400
- target_size_max = np.max(target_size)
2401
-
2402
- if mode == 'long':
2403
- im_scale = min(target_size_min / im_size_min,
2404
- target_size_max / im_size_max)
2405
- else:
2406
- im_scale = max(target_size_min / im_size_min,
2407
- target_size_max / im_size_max)
2408
-
2409
- resize_h = im_scale * float(im_shape[0])
2410
- resize_w = im_scale * float(im_shape[1])
2411
-
2412
- im_scale_x = im_scale
2413
- im_scale_y = im_scale
2414
- else:
2415
- resize_h, resize_w = target_size
2416
- im_scale_y = resize_h / im_shape[0]
2417
- im_scale_x = resize_w / im_shape[1]
2418
-
2419
- im = self.apply_image(sample['image'], [im_scale_x, im_scale_y])
2420
- sample['image'] = im
2421
- sample['im_shape'] = np.asarray([resize_h, resize_w], dtype=np.float32)
2422
- if 'scale_factor' in sample:
2423
- scale_factor = sample['scale_factor']
2424
- sample['scale_factor'] = np.asarray(
2425
- [scale_factor[0] * im_scale_y, scale_factor[1] * im_scale_x],
2426
- dtype=np.float32)
2427
- else:
2428
- sample['scale_factor'] = np.asarray(
2429
- [im_scale_y, im_scale_x], dtype=np.float32)
2430
-
2431
- # apply bbox
2432
- if 'gt_bbox' in sample and len(sample['gt_bbox']) > 0:
2433
- sample['gt_bbox'] = self.apply_bbox(sample['gt_bbox'],
2434
- [im_scale_x, im_scale_y],
2435
- [resize_w, resize_h])
2436
-
2437
- # apply rbox
2438
- if 'gt_rbox2poly' in sample:
2439
- if np.array(sample['gt_rbox2poly']).shape[1] != 8:
2440
- logger.warn(
2441
- "gt_rbox2poly's length shoule be 8, but actually is {}".
2442
- format(len(sample['gt_rbox2poly'])))
2443
- sample['gt_rbox2poly'] = self.apply_bbox(sample['gt_rbox2poly'],
2444
- [im_scale_x, im_scale_y],
2445
- [resize_w, resize_h])
2446
-
2447
- # apply polygon
2448
- if 'gt_poly' in sample and len(sample['gt_poly']) > 0:
2449
- sample['gt_poly'] = self.apply_segm(
2450
- sample['gt_poly'], im_shape[:2], [im_scale_x, im_scale_y])
2451
-
2452
- # apply semantic
2453
- if 'semantic' in sample and sample['semantic']:
2454
- semantic = sample['semantic']
2455
- semantic = cv2.resize(
2456
- semantic.astype('float32'),
2457
- None,
2458
- None,
2459
- fx=im_scale_x,
2460
- fy=im_scale_y,
2461
- interpolation=self.interp)
2462
- semantic = np.asarray(semantic).astype('int32')
2463
- semantic = np.expand_dims(semantic, 0)
2464
- sample['semantic'] = semantic
2465
-
2466
- # apply gt_segm
2467
- if 'gt_segm' in sample and len(sample['gt_segm']) > 0:
2468
- masks = [
2469
- cv2.resize(
2470
- gt_segm,
2471
- None,
2472
- None,
2473
- fx=im_scale_x,
2474
- fy=im_scale_y,
2475
- interpolation=cv2.INTER_NEAREST)
2476
- for gt_segm in sample['gt_segm']
2477
- ]
2478
- sample['gt_segm'] = np.asarray(masks).astype(np.uint8)
2479
-
2480
- return sample
2481
-
2482
-
2483
- @register_op
2484
- class RandomSelect(BaseOperator):
2485
- """
2486
- Randomly choose a transformation between transforms1 and transforms2,
2487
- and the probability of choosing transforms1 is p.
2488
-
2489
- The code is based on https://github.com/facebookresearch/detr/blob/main/datasets/transforms.py
2490
-
2491
- """
2492
-
2493
- def __init__(self, transforms1, transforms2, p=0.5):
2494
- super(RandomSelect, self).__init__()
2495
- self.transforms1 = Compose(transforms1)
2496
- self.transforms2 = Compose(transforms2)
2497
- self.p = p
2498
-
2499
- def apply(self, sample, context=None):
2500
- if random.random() < self.p:
2501
- return self.transforms1(sample)
2502
- return self.transforms2(sample)
2503
-
2504
-
2505
- @register_op
2506
- class RandomShortSideResize(BaseOperator):
2507
- def __init__(self,
2508
- short_side_sizes,
2509
- max_size=None,
2510
- interp=cv2.INTER_LINEAR,
2511
- random_interp=False):
2512
- """
2513
- Resize the image randomly according to the short side. If max_size is not None,
2514
- the long side is scaled according to max_size. The whole process will be keep ratio.
2515
- Args:
2516
- short_side_sizes (list|tuple): Image target short side size.
2517
- max_size (int): The size of the longest side of image after resize.
2518
- interp (int): The interpolation method.
2519
- random_interp (bool): Whether random select interpolation method.
2520
- """
2521
- super(RandomShortSideResize, self).__init__()
2522
-
2523
- assert isinstance(short_side_sizes,
2524
- Sequence), "short_side_sizes must be List or Tuple"
2525
-
2526
- self.short_side_sizes = short_side_sizes
2527
- self.max_size = max_size
2528
- self.interp = interp
2529
- self.random_interp = random_interp
2530
- self.interps = [
2531
- cv2.INTER_NEAREST,
2532
- cv2.INTER_LINEAR,
2533
- cv2.INTER_AREA,
2534
- cv2.INTER_CUBIC,
2535
- cv2.INTER_LANCZOS4,
2536
- ]
2537
-
2538
- def get_size_with_aspect_ratio(self, image_shape, size, max_size=None):
2539
- h, w = image_shape
2540
- if max_size is not None:
2541
- min_original_size = float(min((w, h)))
2542
- max_original_size = float(max((w, h)))
2543
- if max_original_size / min_original_size * size > max_size:
2544
- size = int(
2545
- round(max_size * min_original_size / max_original_size))
2546
-
2547
- if (w <= h and w == size) or (h <= w and h == size):
2548
- return (w, h)
2549
-
2550
- if w < h:
2551
- ow = size
2552
- oh = int(size * h / w)
2553
- else:
2554
- oh = size
2555
- ow = int(size * w / h)
2556
-
2557
- return (ow, oh)
2558
-
2559
- def resize(self,
2560
- sample,
2561
- target_size,
2562
- max_size=None,
2563
- interp=cv2.INTER_LINEAR):
2564
- im = sample['image']
2565
- if not isinstance(im, np.ndarray):
2566
- raise TypeError("{}: image type is not numpy.".format(self))
2567
- if len(im.shape) != 3:
2568
- raise ImageError('{}: image is not 3-dimensional.'.format(self))
2569
-
2570
- target_size = self.get_size_with_aspect_ratio(im.shape[:2],
2571
- target_size, max_size)
2572
- im_scale_y, im_scale_x = target_size[1] / im.shape[0], target_size[
2573
- 0] / im.shape[1]
2574
-
2575
- sample['image'] = cv2.resize(im, target_size, interpolation=interp)
2576
- sample['im_shape'] = np.asarray(target_size[::-1], dtype=np.float32)
2577
- if 'scale_factor' in sample:
2578
- scale_factor = sample['scale_factor']
2579
- sample['scale_factor'] = np.asarray(
2580
- [scale_factor[0] * im_scale_y, scale_factor[1] * im_scale_x],
2581
- dtype=np.float32)
2582
- else:
2583
- sample['scale_factor'] = np.asarray(
2584
- [im_scale_y, im_scale_x], dtype=np.float32)
2585
-
2586
- # apply bbox
2587
- if 'gt_bbox' in sample and len(sample['gt_bbox']) > 0:
2588
- sample['gt_bbox'] = self.apply_bbox(
2589
- sample['gt_bbox'], [im_scale_x, im_scale_y], target_size)
2590
- # apply polygon
2591
- if 'gt_poly' in sample and len(sample['gt_poly']) > 0:
2592
- sample['gt_poly'] = self.apply_segm(
2593
- sample['gt_poly'], im.shape[:2], [im_scale_x, im_scale_y])
2594
- # apply semantic
2595
- if 'semantic' in sample and sample['semantic']:
2596
- semantic = sample['semantic']
2597
- semantic = cv2.resize(
2598
- semantic.astype('float32'),
2599
- target_size,
2600
- interpolation=self.interp)
2601
- semantic = np.asarray(semantic).astype('int32')
2602
- semantic = np.expand_dims(semantic, 0)
2603
- sample['semantic'] = semantic
2604
- # apply gt_segm
2605
- if 'gt_segm' in sample and len(sample['gt_segm']) > 0:
2606
- masks = [
2607
- cv2.resize(
2608
- gt_segm, target_size, interpolation=cv2.INTER_NEAREST)
2609
- for gt_segm in sample['gt_segm']
2610
- ]
2611
- sample['gt_segm'] = np.asarray(masks).astype(np.uint8)
2612
- return sample
2613
-
2614
- def apply_bbox(self, bbox, scale, size):
2615
- im_scale_x, im_scale_y = scale
2616
- resize_w, resize_h = size
2617
- bbox[:, 0::2] *= im_scale_x
2618
- bbox[:, 1::2] *= im_scale_y
2619
- bbox[:, 0::2] = np.clip(bbox[:, 0::2], 0, resize_w)
2620
- bbox[:, 1::2] = np.clip(bbox[:, 1::2], 0, resize_h)
2621
- return bbox.astype('float32')
2622
-
2623
- def apply_segm(self, segms, im_size, scale):
2624
- def _resize_poly(poly, im_scale_x, im_scale_y):
2625
- resized_poly = np.array(poly).astype('float32')
2626
- resized_poly[0::2] *= im_scale_x
2627
- resized_poly[1::2] *= im_scale_y
2628
- return resized_poly.tolist()
2629
-
2630
- def _resize_rle(rle, im_h, im_w, im_scale_x, im_scale_y):
2631
- if 'counts' in rle and type(rle['counts']) == list:
2632
- rle = mask_util.frPyObjects(rle, im_h, im_w)
2633
-
2634
- mask = mask_util.decode(rle)
2635
- mask = cv2.resize(
2636
- mask,
2637
- None,
2638
- None,
2639
- fx=im_scale_x,
2640
- fy=im_scale_y,
2641
- interpolation=self.interp)
2642
- rle = mask_util.encode(np.array(mask, order='F', dtype=np.uint8))
2643
- return rle
2644
-
2645
- im_h, im_w = im_size
2646
- im_scale_x, im_scale_y = scale
2647
- resized_segms = []
2648
- for segm in segms:
2649
- if is_poly(segm):
2650
- # Polygon format
2651
- resized_segms.append([
2652
- _resize_poly(poly, im_scale_x, im_scale_y) for poly in segm
2653
- ])
2654
- else:
2655
- # RLE format
2656
- import pycocotools.mask as mask_util
2657
- resized_segms.append(
2658
- _resize_rle(segm, im_h, im_w, im_scale_x, im_scale_y))
2659
-
2660
- return resized_segms
2661
-
2662
- def apply(self, sample, context=None):
2663
- target_size = random.choice(self.short_side_sizes)
2664
- interp = random.choice(
2665
- self.interps) if self.random_interp else self.interp
2666
-
2667
- return self.resize(sample, target_size, self.max_size, interp)
2668
-
2669
-
2670
- @register_op
2671
- class RandomSizeCrop(BaseOperator):
2672
- """
2673
- Cut the image randomly according to `min_size` and `max_size`
2674
- """
2675
-
2676
- def __init__(self, min_size, max_size):
2677
- super(RandomSizeCrop, self).__init__()
2678
- self.min_size = min_size
2679
- self.max_size = max_size
2680
-
2681
- from paddle.vision.transforms.functional import crop as paddle_crop
2682
- self.paddle_crop = paddle_crop
2683
-
2684
- @staticmethod
2685
- def get_crop_params(img_shape, output_size):
2686
- """Get parameters for ``crop`` for a random crop.
2687
- Args:
2688
- img_shape (list|tuple): Image's height and width.
2689
- output_size (list|tuple): Expected output size of the crop.
2690
- Returns:
2691
- tuple: params (i, j, h, w) to be passed to ``crop`` for random crop.
2692
- """
2693
- h, w = img_shape
2694
- th, tw = output_size
2695
-
2696
- if h + 1 < th or w + 1 < tw:
2697
- raise ValueError(
2698
- "Required crop size {} is larger then input image size {}".
2699
- format((th, tw), (h, w)))
2700
-
2701
- if w == tw and h == th:
2702
- return 0, 0, h, w
2703
-
2704
- i = random.randint(0, h - th + 1)
2705
- j = random.randint(0, w - tw + 1)
2706
- return i, j, th, tw
2707
-
2708
- def crop(self, sample, region):
2709
- image_shape = sample['image'].shape[:2]
2710
- sample['image'] = self.paddle_crop(sample['image'], *region)
2711
-
2712
- keep_index = None
2713
- # apply bbox
2714
- if 'gt_bbox' in sample and len(sample['gt_bbox']) > 0:
2715
- sample['gt_bbox'] = self.apply_bbox(sample['gt_bbox'], region)
2716
- bbox = sample['gt_bbox'].reshape([-1, 2, 2])
2717
- area = (bbox[:, 1, :] - bbox[:, 0, :]).prod(axis=1)
2718
- keep_index = np.where(area > 0)[0]
2719
- sample['gt_bbox'] = sample['gt_bbox'][keep_index] if len(
2720
- keep_index) > 0 else np.zeros(
2721
- [0, 4], dtype=np.float32)
2722
- sample['gt_class'] = sample['gt_class'][keep_index] if len(
2723
- keep_index) > 0 else np.zeros(
2724
- [0, 1], dtype=np.float32)
2725
- if 'gt_score' in sample:
2726
- sample['gt_score'] = sample['gt_score'][keep_index] if len(
2727
- keep_index) > 0 else np.zeros(
2728
- [0, 1], dtype=np.float32)
2729
- if 'is_crowd' in sample:
2730
- sample['is_crowd'] = sample['is_crowd'][keep_index] if len(
2731
- keep_index) > 0 else np.zeros(
2732
- [0, 1], dtype=np.float32)
2733
-
2734
- # apply polygon
2735
- if 'gt_poly' in sample and len(sample['gt_poly']) > 0:
2736
- sample['gt_poly'] = self.apply_segm(sample['gt_poly'], region,
2737
- image_shape)
2738
- if keep_index is not None:
2739
- sample['gt_poly'] = sample['gt_poly'][keep_index]
2740
- # apply gt_segm
2741
- if 'gt_segm' in sample and len(sample['gt_segm']) > 0:
2742
- i, j, h, w = region
2743
- sample['gt_segm'] = sample['gt_segm'][:, i:i + h, j:j + w]
2744
- if keep_index is not None:
2745
- sample['gt_segm'] = sample['gt_segm'][keep_index]
2746
-
2747
- return sample
2748
-
2749
- def apply_bbox(self, bbox, region):
2750
- i, j, h, w = region
2751
- region_size = np.asarray([w, h])
2752
- crop_bbox = bbox - np.asarray([j, i, j, i])
2753
- crop_bbox = np.minimum(crop_bbox.reshape([-1, 2, 2]), region_size)
2754
- crop_bbox = crop_bbox.clip(min=0)
2755
- return crop_bbox.reshape([-1, 4]).astype('float32')
2756
-
2757
- def apply_segm(self, segms, region, image_shape):
2758
- def _crop_poly(segm, crop):
2759
- xmin, ymin, xmax, ymax = crop
2760
- crop_coord = [xmin, ymin, xmin, ymax, xmax, ymax, xmax, ymin]
2761
- crop_p = np.array(crop_coord).reshape(4, 2)
2762
- crop_p = Polygon(crop_p)
2763
-
2764
- crop_segm = list()
2765
- for poly in segm:
2766
- poly = np.array(poly).reshape(len(poly) // 2, 2)
2767
- polygon = Polygon(poly)
2768
- if not polygon.is_valid:
2769
- exterior = polygon.exterior
2770
- multi_lines = exterior.intersection(exterior)
2771
- polygons = shapely.ops.polygonize(multi_lines)
2772
- polygon = MultiPolygon(polygons)
2773
- multi_polygon = list()
2774
- if isinstance(polygon, MultiPolygon):
2775
- multi_polygon = copy.deepcopy(polygon)
2776
- else:
2777
- multi_polygon.append(copy.deepcopy(polygon))
2778
- for per_polygon in multi_polygon:
2779
- inter = per_polygon.intersection(crop_p)
2780
- if not inter:
2781
- continue
2782
- if isinstance(inter, (MultiPolygon, GeometryCollection)):
2783
- for part in inter:
2784
- if not isinstance(part, Polygon):
2785
- continue
2786
- part = np.squeeze(
2787
- np.array(part.exterior.coords[:-1]).reshape(
2788
- 1, -1))
2789
- part[0::2] -= xmin
2790
- part[1::2] -= ymin
2791
- crop_segm.append(part.tolist())
2792
- elif isinstance(inter, Polygon):
2793
- crop_poly = np.squeeze(
2794
- np.array(inter.exterior.coords[:-1]).reshape(1,
2795
- -1))
2796
- crop_poly[0::2] -= xmin
2797
- crop_poly[1::2] -= ymin
2798
- crop_segm.append(crop_poly.tolist())
2799
- else:
2800
- continue
2801
- return crop_segm
2802
-
2803
- def _crop_rle(rle, crop, height, width):
2804
- if 'counts' in rle and type(rle['counts']) == list:
2805
- rle = mask_util.frPyObjects(rle, height, width)
2806
- mask = mask_util.decode(rle)
2807
- mask = mask[crop[1]:crop[3], crop[0]:crop[2]]
2808
- rle = mask_util.encode(np.array(mask, order='F', dtype=np.uint8))
2809
- return rle
2810
-
2811
- i, j, h, w = region
2812
- crop = [j, i, j + w, i + h]
2813
- height, width = image_shape
2814
- crop_segms = []
2815
- for segm in segms:
2816
- if is_poly(segm):
2817
- import copy
2818
- import shapely.ops
2819
- from shapely.geometry import Polygon, MultiPolygon, GeometryCollection
2820
- # Polygon format
2821
- crop_segms.append(_crop_poly(segm, crop))
2822
- else:
2823
- # RLE format
2824
- import pycocotools.mask as mask_util
2825
- crop_segms.append(_crop_rle(segm, crop, height, width))
2826
- return crop_segms
2827
-
2828
- def apply(self, sample, context=None):
2829
- h = random.randint(self.min_size,
2830
- min(sample['image'].shape[0], self.max_size))
2831
- w = random.randint(self.min_size,
2832
- min(sample['image'].shape[1], self.max_size))
2833
-
2834
- region = self.get_crop_params(sample['image'].shape[:2], [h, w])
2835
- return self.crop(sample, region)
2836
-
2837
-
2838
- @register_op
2839
- class WarpAffine(BaseOperator):
2840
- def __init__(self,
2841
- keep_res=False,
2842
- pad=31,
2843
- input_h=512,
2844
- input_w=512,
2845
- scale=0.4,
2846
- shift=0.1):
2847
- """WarpAffine
2848
- Warp affine the image
2849
-
2850
- The code is based on https://github.com/xingyizhou/CenterNet/blob/master/src/lib/datasets/sample/ctdet.py
2851
-
2852
-
2853
- """
2854
- super(WarpAffine, self).__init__()
2855
- self.keep_res = keep_res
2856
- self.pad = pad
2857
- self.input_h = input_h
2858
- self.input_w = input_w
2859
- self.scale = scale
2860
- self.shift = shift
2861
-
2862
- def apply(self, sample, context=None):
2863
- img = sample['image']
2864
- img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
2865
- if 'gt_bbox' in sample and len(sample['gt_bbox']) == 0:
2866
- return sample
2867
-
2868
- h, w = img.shape[:2]
2869
-
2870
- if self.keep_res:
2871
- input_h = (h | self.pad) + 1
2872
- input_w = (w | self.pad) + 1
2873
- s = np.array([input_w, input_h], dtype=np.float32)
2874
- c = np.array([w // 2, h // 2], dtype=np.float32)
2875
-
2876
- else:
2877
- s = max(h, w) * 1.0
2878
- input_h, input_w = self.input_h, self.input_w
2879
- c = np.array([w / 2., h / 2.], dtype=np.float32)
2880
-
2881
- trans_input = get_affine_transform(c, s, 0, [input_w, input_h])
2882
- img = cv2.resize(img, (w, h))
2883
- inp = cv2.warpAffine(
2884
- img, trans_input, (input_w, input_h), flags=cv2.INTER_LINEAR)
2885
- sample['image'] = inp
2886
- return sample
2887
-
2888
-
2889
- @register_op
2890
- class FlipWarpAffine(BaseOperator):
2891
- def __init__(self,
2892
- keep_res=False,
2893
- pad=31,
2894
- input_h=512,
2895
- input_w=512,
2896
- not_rand_crop=False,
2897
- scale=0.4,
2898
- shift=0.1,
2899
- flip=0.5,
2900
- is_scale=True,
2901
- use_random=True):
2902
- """FlipWarpAffine
2903
- 1. Random Crop
2904
- 2. Flip the image horizontal
2905
- 3. Warp affine the image
2906
- """
2907
- super(FlipWarpAffine, self).__init__()
2908
- self.keep_res = keep_res
2909
- self.pad = pad
2910
- self.input_h = input_h
2911
- self.input_w = input_w
2912
- self.not_rand_crop = not_rand_crop
2913
- self.scale = scale
2914
- self.shift = shift
2915
- self.flip = flip
2916
- self.is_scale = is_scale
2917
- self.use_random = use_random
2918
-
2919
- def apply(self, sample, context=None):
2920
- img = sample['image']
2921
- img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
2922
- if 'gt_bbox' in sample and len(sample['gt_bbox']) == 0:
2923
- return sample
2924
-
2925
- h, w = img.shape[:2]
2926
-
2927
- if self.keep_res:
2928
- input_h = (h | self.pad) + 1
2929
- input_w = (w | self.pad) + 1
2930
- s = np.array([input_w, input_h], dtype=np.float32)
2931
- c = np.array([w // 2, h // 2], dtype=np.float32)
2932
-
2933
- else:
2934
- s = max(h, w) * 1.0
2935
- input_h, input_w = self.input_h, self.input_w
2936
- c = np.array([w / 2., h / 2.], dtype=np.float32)
2937
-
2938
- if self.use_random:
2939
- gt_bbox = sample['gt_bbox']
2940
- if not self.not_rand_crop:
2941
- s = s * np.random.choice(np.arange(0.6, 1.4, 0.1))
2942
- w_border = get_border(128, w)
2943
- h_border = get_border(128, h)
2944
- c[0] = np.random.randint(low=w_border, high=w - w_border)
2945
- c[1] = np.random.randint(low=h_border, high=h - h_border)
2946
- else:
2947
- sf = self.scale
2948
- cf = self.shift
2949
- c[0] += s * np.clip(np.random.randn() * cf, -2 * cf, 2 * cf)
2950
- c[1] += s * np.clip(np.random.randn() * cf, -2 * cf, 2 * cf)
2951
- s = s * np.clip(np.random.randn() * sf + 1, 1 - sf, 1 + sf)
2952
-
2953
- if np.random.random() < self.flip:
2954
- img = img[:, ::-1, :]
2955
- c[0] = w - c[0] - 1
2956
- oldx1 = gt_bbox[:, 0].copy()
2957
- oldx2 = gt_bbox[:, 2].copy()
2958
- gt_bbox[:, 0] = w - oldx2 - 1
2959
- gt_bbox[:, 2] = w - oldx1 - 1
2960
- sample['gt_bbox'] = gt_bbox
2961
-
2962
- trans_input = get_affine_transform(c, s, 0, [input_w, input_h])
2963
- if not self.use_random:
2964
- img = cv2.resize(img, (w, h))
2965
- inp = cv2.warpAffine(
2966
- img, trans_input, (input_w, input_h), flags=cv2.INTER_LINEAR)
2967
- if self.is_scale:
2968
- inp = (inp.astype(np.float32) / 255.)
2969
- sample['image'] = inp
2970
- sample['center'] = c
2971
- sample['scale'] = s
2972
- return sample
2973
-
2974
-
2975
- @register_op
2976
- class CenterRandColor(BaseOperator):
2977
- """Random color for CenterNet series models.
2978
- Args:
2979
- saturation (float): saturation settings.
2980
- contrast (float): contrast settings.
2981
- brightness (float): brightness settings.
2982
- """
2983
-
2984
- def __init__(self, saturation=0.4, contrast=0.4, brightness=0.4):
2985
- super(CenterRandColor, self).__init__()
2986
- self.saturation = saturation
2987
- self.contrast = contrast
2988
- self.brightness = brightness
2989
-
2990
- def apply_saturation(self, img, img_gray):
2991
- alpha = 1. + np.random.uniform(
2992
- low=-self.saturation, high=self.saturation)
2993
- self._blend(alpha, img, img_gray[:, :, None])
2994
- return img
2995
-
2996
- def apply_contrast(self, img, img_gray):
2997
- alpha = 1. + np.random.uniform(low=-self.contrast, high=self.contrast)
2998
- img_mean = img_gray.mean()
2999
- self._blend(alpha, img, img_mean)
3000
- return img
3001
-
3002
- def apply_brightness(self, img, img_gray):
3003
- alpha = 1 + np.random.uniform(
3004
- low=-self.brightness, high=self.brightness)
3005
- img *= alpha
3006
- return img
3007
-
3008
- def _blend(self, alpha, img, img_mean):
3009
- img *= alpha
3010
- img_mean *= (1 - alpha)
3011
- img += img_mean
3012
-
3013
- def __call__(self, sample, context=None):
3014
- img = sample['image']
3015
- img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
3016
- functions = [
3017
- self.apply_brightness,
3018
- self.apply_contrast,
3019
- self.apply_saturation,
3020
- ]
3021
- distortions = np.random.permutation(functions)
3022
- for func in distortions:
3023
- img = func(img, img_gray)
3024
- sample['image'] = img
3025
- return sample