From 4c0eaa409d6f252a200854e6bd1c87887930946e Mon Sep 17 00:00:00 2001 From: Aditya Putra Pratama Date: Mon, 10 Jun 2024 15:06:10 +0700 Subject: [PATCH 1/2] update scrfd_person.py numpy int deprecated --- examples/person_detection/scrfd_person.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/person_detection/scrfd_person.py b/examples/person_detection/scrfd_person.py index e2422b0a1..c6f7d2d3c 100644 --- a/examples/person_detection/scrfd_person.py +++ b/examples/person_detection/scrfd_person.py @@ -11,8 +11,8 @@ def detect_person(img, detector): bboxes, kpss = detector.detect(img) - bboxes = np.round(bboxes[:,:4]).astype(np.int) - kpss = np.round(kpss).astype(np.int) + bboxes = np.round(bboxes[:,:4]).astype(np.int32) + kpss = np.round(kpss).astype(np.int32) kpss[:,:,0] = np.clip(kpss[:,:,0], 0, img.shape[1]) kpss[:,:,1] = np.clip(kpss[:,:,1], 0, img.shape[0]) vbboxes = bboxes.copy() From 60fc1226b7b80a4b3e2fdc6ab0798e72dd666cae Mon Sep 17 00:00:00 2001 From: adityapp Date: Mon, 30 Sep 2024 22:30:37 +0700 Subject: [PATCH 2/2] update np.int32 and np.float32 --- alignment/coordinate_reg/image_infer.py | 2 +- alignment/heatmap/metric.py | 2 +- alignment/synthetics/datasets/augs.py | 2 +- alignment/synthetics/test_synthetics.py | 4 ++-- .../synthetics/tools/prepare_synthetics.py | 4 ++-- .../retinaface/rcnn/PY_OP/cascade_refine.py | 10 ++++---- detection/retinaface/rcnn/core/loader.py | 2 +- detection/retinaface/rcnn/core/tester.py | 4 ++-- detection/retinaface/rcnn/cython/bbox.pyx | 2 +- detection/retinaface/rcnn/cython/cpu_nms.pyx | 4 ++-- detection/retinaface/rcnn/cython/gpu_nms.pyx | 2 +- detection/retinaface/rcnn/dataset/ds_utils.py | 2 +- detection/retinaface/rcnn/dataset/imdb.py | 8 +++---- .../retinaface/rcnn/dataset/retinaface.py | 12 +++++----- detection/retinaface/rcnn/io/image.py | 24 +++++++++---------- detection/retinaface/rcnn/io/rcnn.py | 16 ++++++------- detection/retinaface/rcnn/io/rpn.py | 8 +++---- .../rcnn/processing/bbox_regression.py | 4 ++-- .../rcnn/processing/bbox_transform.py | 8 +++---- .../retinaface/rcnn/pycocotools/cocoeval.py | 4 ++-- detection/retinaface/retinaface.py | 4 ++-- detection/retinaface/test.py | 4 ++-- detection/retinaface/test_widerface.py | 6 ++--- .../rcnn/processing/bbox_regression.py | 4 ++-- .../rcnn/processing/bbox_transform.py | 8 +++---- .../rcnn/processing/bbox_transform.py.orig | 8 +++---- .../retinaface_anticov/retinaface_cov.py | 4 ++-- detection/retinaface_anticov/test.py | 4 ++-- .../bbox/samplers/iou_balanced_neg_sampler.py | 6 ++--- .../scrfd/mmdet/core/evaluation/widerface.py | 8 +++---- detection/scrfd/mmdet/datasets/custom.py | 2 +- .../mmdet/datasets/pipelines/transforms.py | 2 +- .../models/roi_heads/bbox_heads/bbox_head.py | 2 +- detection/scrfd/tools/scrfd.py | 4 ++-- parsing/dml_csr/loss/criterion.py | 10 ++++---- python-package/insightface/model_zoo/scrfd.py | 4 ++-- recognition/_evaluation_/ijb/ijb_11.py | 12 +++++----- recognition/_evaluation_/ijb/ijb_1n.py | 14 +++++------ recognition/_evaluation_/ijb/ijb_onnx.py | 10 ++++---- recognition/arcface_oneflow/eval/onnx_ijbc.py | 10 ++++---- recognition/arcface_torch/eval_ijbc.py | 12 +++++----- recognition/arcface_torch/onnx_ijbc.py | 10 ++++---- recognition/arcface_torch/torch2onnx.py | 2 +- recognition/arcface_torch/utils/plot.py | 6 ++--- .../partial_fc/mxnet/evaluation/ijb.py | 10 ++++---- recognition/subcenter_arcface/drop.py | 2 +- recognition/vpl/eval_ijbc.py | 12 +++++----- recognition/vpl/onnx_ijbc.py | 10 ++++---- recognition/vpl/torch2onnx.py | 2 +- recognition/vpl/utils/plot.py | 6 ++--- reconstruction/PBIDR/code/utils/plots.py | 2 +- reconstruction/gaze/datasets/augs.py | 2 +- reconstruction/gaze/test_gaze.py | 14 +++++------ reconstruction/jmlr/dataset.py | 6 ++--- reconstruction/jmlr/utils/plot.py | 6 ++--- reconstruction/ostec/core/operator.py | 6 ++--- .../ostec/external/landmark_detector/utils.py | 2 +- reconstruction/ostec/utils/align2stylegan.py | 4 ++-- reconstruction/ostec/utils/utils.py | 4 ++-- 59 files changed, 184 insertions(+), 184 deletions(-) diff --git a/alignment/coordinate_reg/image_infer.py b/alignment/coordinate_reg/image_infer.py index a336221e8..3665b1222 100644 --- a/alignment/coordinate_reg/image_infer.py +++ b/alignment/coordinate_reg/image_infer.py @@ -15,7 +15,7 @@ color = (200, 160, 75) for face in faces: lmk = face.landmark_2d_106 - lmk = np.round(lmk).astype(np.int) + lmk = np.round(lmk).astype(np.int32) for i in range(lmk.shape[0]): p = tuple(lmk[i]) cv2.circle(tim, p, 1, color, 1, cv2.LINE_AA) diff --git a/alignment/heatmap/metric.py b/alignment/heatmap/metric.py index 2ddc96c9f..f2431aa08 100644 --- a/alignment/heatmap/metric.py +++ b/alignment/heatmap/metric.py @@ -51,7 +51,7 @@ def cal_nme(self, label, pred_label): ind_gt = np.array(ind_gt) else: ind_gt = label[b][p] - #ind_gt = ind_gt.astype(np.int) + #ind_gt = ind_gt.astype(np.int32) #print(ind_gt) heatmap_pred = pred_label[b][p] heatmap_pred = cv2.resize( diff --git a/alignment/synthetics/datasets/augs.py b/alignment/synthetics/datasets/augs.py index 08f47fccd..1ac0a047b 100644 --- a/alignment/synthetics/datasets/augs.py +++ b/alignment/synthetics/datasets/augs.py @@ -24,7 +24,7 @@ def apply(self, image, border_size_limit, **params): border_size[2] *= image.shape[1] border_size[1] *= image.shape[0] border_size[3] *= image.shape[0] - border_size = border_size.astype(np.int) + border_size = border_size.astype(np.int32) image[:,:border_size[0],:] = self.fill_value image[:border_size[1],:,:] = self.fill_value image[:,-border_size[2]:,:] = self.fill_value diff --git a/alignment/synthetics/test_synthetics.py b/alignment/synthetics/test_synthetics.py index e1a46f810..abdfb40ba 100644 --- a/alignment/synthetics/test_synthetics.py +++ b/alignment/synthetics/test_synthetics.py @@ -85,10 +85,10 @@ outf.write(' ') outf.write(' '.join(["%.5f"%x for x in kps.flatten()])) outf.write("\n") - box = bbox.astype(np.int) + box = bbox.astype(np.int32) color = (0, 0, 255) cv2.rectangle(dimg, (box[0], box[1]), (box[2], box[3]), color, 2) - kps = kps.astype(np.int) + kps = kps.astype(np.int32) #print(landmark.shape) for l in range(kps.shape[0]): color = (0, 0, 255) diff --git a/alignment/synthetics/tools/prepare_synthetics.py b/alignment/synthetics/tools/prepare_synthetics.py index 5e977d611..8dcafa101 100644 --- a/alignment/synthetics/tools/prepare_synthetics.py +++ b/alignment/synthetics/tools/prepare_synthetics.py @@ -48,11 +48,11 @@ _scale = output_size / (max(w, h)*1.5) aimg, M = face_align.transform(dimg, center, output_size, _scale, rotate) pred = face_align.trans_points(pred, M) - #box = bbox.astype(np.int) + #box = bbox.astype(np.int32) #color = (0, 0, 255) #cv2.rectangle(dimg, (box[0], box[1]), (box[2], box[3]), color, 2) - #kps = pred.astype(np.int) + #kps = pred.astype(np.int32) #for l in range(kps.shape[0]): # color = (0, 0, 255) # cv2.circle(aimg, (kps[l][0], kps[l][1]), 1, color, 2) diff --git a/detection/retinaface/rcnn/PY_OP/cascade_refine.py b/detection/retinaface/rcnn/PY_OP/cascade_refine.py index e3c6556fa..a073963a6 100644 --- a/detection/retinaface/rcnn/PY_OP/cascade_refine.py +++ b/detection/retinaface/rcnn/PY_OP/cascade_refine.py @@ -127,8 +127,8 @@ def assign_anchor_fpn(self, if gt_boxes.size > 0: # overlap between the anchors and the gt boxes # overlaps (ex, gt) - overlaps = bbox_overlaps(anchors.astype(np.float), - gt_boxes.astype(np.float)) + overlaps = bbox_overlaps(anchors.astype(np.float32), + gt_boxes.astype(np.float32)) argmax_overlaps = overlaps.argmax(axis=1) #print('AAA', argmax_overlaps.shape) max_overlaps = overlaps[np.arange(num_anchors), argmax_overlaps] @@ -344,13 +344,13 @@ def forward(self, is_train, req, in_data, out_data, aux): assert anchors_t1.shape[0] == self.ori_anchors.shape[0] #for i in range(_gt_boxes.shape[0]): - # box = _gt_boxes[i].astype(np.int) + # box = _gt_boxes[i].astype(np.int32) # print('%d: gt%d'%(self.nbatch, i), box) # #color = (0,0,255) # #cv2.rectangle(img, (box[0], box[1]), (box[2], box[3]), color, 2) #for i in range(anchors_t1.shape[0]): - # box1 = self.ori_anchors[i].astype(np.int) - # box2 = anchors_t1[i].astype(np.int) + # box1 = self.ori_anchors[i].astype(np.int32) + # box2 = anchors_t1[i].astype(np.int32) # print('%d %d: anchorscompare %d'%(self.nbatch, self.stride, i), box1, box2) #color = (255,255,0) #cv2.rectangle(img, (box[0], box[1]), (box[2], box[3]), color, 2) diff --git a/detection/retinaface/rcnn/core/loader.py b/detection/retinaface/rcnn/core/loader.py index 1d34d2eb3..7b655c456 100644 --- a/detection/retinaface/rcnn/core/loader.py +++ b/detection/retinaface/rcnn/core/loader.py @@ -247,7 +247,7 @@ def get_batch(self): print('DEBUG SHAPE', data['data'].shape, label['gt_boxes'].shape) - box = label['gt_boxes'].copy()[0][0:4].astype(np.int) + box = label['gt_boxes'].copy()[0][0:4].astype(np.int32) cv2.rectangle(img, (box[0], box[1]), (box[2], box[3]), (0, 255, 0), 2) filename = './debugout/%d.png' % (self._debug_id) diff --git a/detection/retinaface/rcnn/core/tester.py b/detection/retinaface/rcnn/core/tester.py index d9d5d32b1..39eb5fa79 100644 --- a/detection/retinaface/rcnn/core/tester.py +++ b/detection/retinaface/rcnn/core/tester.py @@ -238,8 +238,8 @@ def test_proposals(predictor, test_data, imdb, roidb, vis=False): gt_boxes[:, 1] + 1) num_pos += gt_boxes.shape[0] - overlaps = bbox_overlaps(boxes.astype(np.float), - gt_boxes.astype(np.float)) + overlaps = bbox_overlaps(boxes.astype(np.float32), + gt_boxes.astype(np.float32)) #print(im_info, gt_boxes.shape, boxes.shape, overlaps.shape, file=sys.stderr) _gt_overlaps = np.zeros((gt_boxes.shape[0])) diff --git a/detection/retinaface/rcnn/cython/bbox.pyx b/detection/retinaface/rcnn/cython/bbox.pyx index 0c49e120e..eea917d92 100644 --- a/detection/retinaface/rcnn/cython/bbox.pyx +++ b/detection/retinaface/rcnn/cython/bbox.pyx @@ -9,7 +9,7 @@ cimport cython import numpy as np cimport numpy as np -DTYPE = np.float +DTYPE = np.float32 ctypedef np.float_t DTYPE_t def bbox_overlaps_cython( diff --git a/detection/retinaface/rcnn/cython/cpu_nms.pyx b/detection/retinaface/rcnn/cython/cpu_nms.pyx index 1d0bef332..7e1c2a3f9 100644 --- a/detection/retinaface/rcnn/cython/cpu_nms.pyx +++ b/detection/retinaface/rcnn/cython/cpu_nms.pyx @@ -14,7 +14,7 @@ cdef inline np.float32_t max(np.float32_t a, np.float32_t b): cdef inline np.float32_t min(np.float32_t a, np.float32_t b): return a if a <= b else b -def cpu_nms(np.ndarray[np.float32_t, ndim=2] dets, np.float thresh): +def cpu_nms(np.ndarray[np.float32_t, ndim=2] dets, np.float32 thresh): cdef np.ndarray[np.float32_t, ndim=1] x1 = dets[:, 0] cdef np.ndarray[np.float32_t, ndim=1] y1 = dets[:, 1] cdef np.ndarray[np.float32_t, ndim=1] x2 = dets[:, 2] @@ -26,7 +26,7 @@ def cpu_nms(np.ndarray[np.float32_t, ndim=2] dets, np.float thresh): cdef int ndets = dets.shape[0] cdef np.ndarray[np.int_t, ndim=1] suppressed = \ - np.zeros((ndets), dtype=np.int) + np.zeros((ndets), dtype=np.int32) # nominal indices cdef int _i, _j diff --git a/detection/retinaface/rcnn/cython/gpu_nms.pyx b/detection/retinaface/rcnn/cython/gpu_nms.pyx index 59d84afe9..7d2f7063e 100644 --- a/detection/retinaface/rcnn/cython/gpu_nms.pyx +++ b/detection/retinaface/rcnn/cython/gpu_nms.pyx @@ -13,7 +13,7 @@ assert sizeof(int) == sizeof(np.int32_t) cdef extern from "gpu_nms.hpp": void _nms(np.int32_t*, int*, np.float32_t*, int, int, float, int) -def gpu_nms(np.ndarray[np.float32_t, ndim=2] dets, np.float thresh, +def gpu_nms(np.ndarray[np.float32_t, ndim=2] dets, np.float32 thresh, np.int32_t device_id=0): cdef int boxes_num = dets.shape[0] cdef int boxes_dim = dets.shape[1] diff --git a/detection/retinaface/rcnn/dataset/ds_utils.py b/detection/retinaface/rcnn/dataset/ds_utils.py index 9432515ee..9f88b6c5e 100644 --- a/detection/retinaface/rcnn/dataset/ds_utils.py +++ b/detection/retinaface/rcnn/dataset/ds_utils.py @@ -4,7 +4,7 @@ def unique_boxes(boxes, scale=1.0): """ return indices of unique boxes """ v = np.array([1, 1e3, 1e6, 1e9]) - hashes = np.round(boxes * scale).dot(v).astype(np.int) + hashes = np.round(boxes * scale).dot(v).astype(np.int32) _, index = np.unique(hashes, return_index=True) return np.sort(index) diff --git a/detection/retinaface/rcnn/dataset/imdb.py b/detection/retinaface/rcnn/dataset/imdb.py index 3c19817a8..cb64fb036 100644 --- a/detection/retinaface/rcnn/dataset/imdb.py +++ b/detection/retinaface/rcnn/dataset/imdb.py @@ -133,8 +133,8 @@ def create_roidb_from_box_list(self, box_list, gt_roidb): gt_boxes = gt_roidb[i]['boxes'] gt_classes = gt_roidb[i]['gt_classes'] # n boxes and k gt_boxes => n * k overlap - gt_overlaps = bbox_overlaps(boxes.astype(np.float), - gt_boxes.astype(np.float)) + gt_overlaps = bbox_overlaps(boxes.astype(np.float32), + gt_boxes.astype(np.float32)) # for each box in n boxes, select only maximum overlap (must be greater than zero) argmaxes = gt_overlaps.argmax(axis=1) maxes = gt_overlaps.max(axis=1) @@ -285,8 +285,8 @@ def evaluate_recall(self, roidb, candidate_boxes=None, thresholds=None): if boxes.shape[0] == 0: continue - overlaps = bbox_overlaps(boxes.astype(np.float), - gt_boxes.astype(np.float)) + overlaps = bbox_overlaps(boxes.astype(np.float32), + gt_boxes.astype(np.float32)) _gt_overlaps = np.zeros((gt_boxes.shape[0])) # choose whatever is smaller to iterate diff --git a/detection/retinaface/rcnn/dataset/retinaface.py b/detection/retinaface/rcnn/dataset/retinaface.py index 6e3b85689..edae8871b 100644 --- a/detection/retinaface/rcnn/dataset/retinaface.py +++ b/detection/retinaface/rcnn/dataset/retinaface.py @@ -75,13 +75,13 @@ def gt_roidb(self): roi = {'image': image_path} roidb.append(roi) continue - boxes = np.zeros([len(self._fp_bbox_map[fp]), 4], np.float) - landmarks = np.zeros([len(self._fp_bbox_map[fp]), 5, 3], np.float) - blur = np.zeros((len(self._fp_bbox_map[fp]), ), np.float) + boxes = np.zeros([len(self._fp_bbox_map[fp]), 4], np.float32) + landmarks = np.zeros([len(self._fp_bbox_map[fp]), 5, 3], np.float32) + blur = np.zeros((len(self._fp_bbox_map[fp]), ), np.float32) boxes_mask = [] gt_classes = np.ones([len(self._fp_bbox_map[fp])], np.int32) - overlaps = np.zeros([len(self._fp_bbox_map[fp]), 2], np.float) + overlaps = np.zeros([len(self._fp_bbox_map[fp]), 2], np.float32) imsize = cv2.imread(os.path.join(self._imgs_path, fp)).shape[0:2][::-1] @@ -106,14 +106,14 @@ def gt_roidb(self): if ( x2 - x1 ) < config.BBOX_MASK_THRESH or y2 - y1 < config.BBOX_MASK_THRESH: - boxes_mask.append(np.array([x1, y1, x2, y2], np.float)) + boxes_mask.append(np.array([x1, y1, x2, y2], np.float32)) continue if ( x2 - x1 ) < config.TRAIN.MIN_BOX_SIZE or y2 - y1 < config.TRAIN.MIN_BOX_SIZE: continue - boxes[ix, :] = np.array([x1, y1, x2, y2], np.float) + boxes[ix, :] = np.array([x1, y1, x2, y2], np.float32) if self._split == 'train': landmark = np.array(values[4:19], dtype=np.float32).reshape((5, 3)) diff --git a/detection/retinaface/rcnn/io/image.py b/detection/retinaface/rcnn/io/image.py index 0296fb4de..bb2cd5a85 100644 --- a/detection/retinaface/rcnn/io/image.py +++ b/detection/retinaface/rcnn/io/image.py @@ -95,7 +95,7 @@ def get_image(roidb, scale=False): if 'boxes_mask' in roi_rec: im = im.astype(np.float32) boxes_mask = roi_rec['boxes_mask'].copy() * im_scale - boxes_mask = boxes_mask.astype(np.int) + boxes_mask = boxes_mask.astype(np.int32) for j in range(boxes_mask.shape[0]): m = boxes_mask[j] im_tensor[:, :, m[1]:m[3], m[0]:m[2]] = 0.0 @@ -156,7 +156,7 @@ def __get_crop_image(roidb): if 'boxes_mask' in roi_rec: #im = im.astype(np.float32) boxes_mask = roi_rec['boxes_mask'].copy() - boxes_mask = boxes_mask.astype(np.int) + boxes_mask = boxes_mask.astype(np.int32) for j in range(boxes_mask.shape[0]): m = boxes_mask[j] im[m[1]:m[3], m[0]:m[2], :] = 0 @@ -197,7 +197,7 @@ def __get_crop_image(roidb): fy=im_scale, interpolation=cv2.INTER_LINEAR) new_rec['boxes'] = roi_rec['boxes'].copy() * im_scale - box_scale = new_rec['boxes'][box_ind].copy().astype(np.int) + box_scale = new_rec['boxes'][box_ind].copy().astype(np.int32) ul_min = box_scale[2:4] - SIZE ul_max = box_scale[0:2] assert ul_min[0] <= ul_max[0] @@ -215,7 +215,7 @@ def __get_crop_image(roidb): im = cv2.warpAffine(im, M, (SIZE, SIZE), borderValue=tuple(config.PIXEL_MEANS)) - #tbox = np.array([left, left+SIZE, up, up+SIZE], dtype=np.int) + #tbox = np.array([left, left+SIZE, up, up+SIZE], dtype=np.int32) #im_new = np.zeros( (SIZE, SIZE,3), dtype=im.dtype) #for i in range(3): # im_new[:,:,i] = config.PIXEL_MEANS[i] @@ -223,7 +223,7 @@ def __get_crop_image(roidb): new_rec['boxes'][:, 2] -= left new_rec['boxes'][:, 1] -= up new_rec['boxes'][:, 3] -= up - box_trans = new_rec['boxes'][box_ind].copy().astype(np.int) + box_trans = new_rec['boxes'][box_ind].copy().astype(np.int32) #print('sel box', im_scale, box, box_scale, box_trans, file=sys.stderr) #print('before', new_rec['boxes'].shape[0]) boxes_new = [] @@ -249,7 +249,7 @@ def __get_crop_image(roidb): if TMP_ID < 10: tim = im.copy() for i in range(new_rec['boxes'].shape[0]): - box = new_rec['boxes'][i].copy().astype(np.int) + box = new_rec['boxes'][i].copy().astype(np.int32) cv2.rectangle(tim, (box[0], box[1]), (box[2], box[3]), (255, 0, 0), 1) filename = './trainimages/train%d.png' % TMP_ID @@ -320,7 +320,7 @@ def get_crop_image1(roidb): if 'boxes_mask' in roi_rec: #im = im.astype(np.float32) boxes_mask = roi_rec['boxes_mask'].copy() - boxes_mask = boxes_mask.astype(np.int) + boxes_mask = boxes_mask.astype(np.int32) for j in range(boxes_mask.shape[0]): m = boxes_mask[j] im[m[1]:m[3], m[0]:m[2], :] = 127 @@ -437,7 +437,7 @@ def get_crop_image1(roidb): if TMP_ID >= 0 and TMP_ID < 10: tim = im.copy().astype(np.uint8) for i in range(new_rec['boxes'].shape[0]): - box = new_rec['boxes'][i].copy().astype(np.int) + box = new_rec['boxes'][i].copy().astype(np.int32) cv2.rectangle(tim, (box[0], box[1]), (box[2], box[3]), (255, 0, 0), 1) print('draw box:', box) @@ -447,7 +447,7 @@ def get_crop_image1(roidb): if landmark[0][2] < 0: print('zero', landmark) continue - landmark = landmark.astype(np.int) + landmark = landmark.astype(np.int32) print('draw landmark', landmark) for k in range(5): color = (0, 0, 255) @@ -498,7 +498,7 @@ def get_crop_image2(roidb): if 'boxes_mask' in roi_rec: #im = im.astype(np.float32) boxes_mask = roi_rec['boxes_mask'].copy() - boxes_mask = boxes_mask.astype(np.int) + boxes_mask = boxes_mask.astype(np.int32) for j in range(boxes_mask.shape[0]): m = boxes_mask[j] im[m[1]:m[3], m[0]:m[2], :] = 0 @@ -697,7 +697,7 @@ def get_crop_image2(roidb): if TMP_ID >= 0 and TMP_ID < 10: tim = im.copy().astype(np.uint8) for i in range(new_rec['boxes'].shape[0]): - box = new_rec['boxes'][i].copy().astype(np.int) + box = new_rec['boxes'][i].copy().astype(np.int32) cv2.rectangle(tim, (box[0], box[1]), (box[2], box[3]), (255, 0, 0), 1) print('draw box:', box) @@ -707,7 +707,7 @@ def get_crop_image2(roidb): if landmark[10] == 0.0: print('zero', landmark) continue - landmark = landmark.astype(np.int) + landmark = landmark.astype(np.int32) print('draw landmark', landmark) for k in range(5): color = (0, 0, 255) diff --git a/detection/retinaface/rcnn/io/rcnn.py b/detection/retinaface/rcnn/io/rcnn.py index 1b3a443f6..3c56184e8 100644 --- a/detection/retinaface/rcnn/io/rcnn.py +++ b/detection/retinaface/rcnn/io/rcnn.py @@ -128,8 +128,8 @@ def sample_rois(rois, :return: (labels, rois, bbox_targets, bbox_weights) """ if labels is None: - overlaps = bbox_overlaps(rois[:, 1:].astype(np.float), - gt_boxes[:, :4].astype(np.float)) + overlaps = bbox_overlaps(rois[:, 1:].astype(np.float32), + gt_boxes[:, :4].astype(np.float32)) gt_assignment = overlaps.argmax(axis=1) overlaps = overlaps.max(axis=1) labels = gt_boxes[gt_assignment, 4] @@ -345,8 +345,8 @@ def sample_rois(rois, overlaps = np.zeros((len(rois), )) labels = np.zeros((len(rois), )) else: - overlaps = bbox_overlaps(rois[:, 1:].astype(np.float), - gt_boxes[:, :4].astype(np.float)) + overlaps = bbox_overlaps(rois[:, 1:].astype(np.float32), + gt_boxes[:, :4].astype(np.float32)) gt_assignment = overlaps.argmax(axis=1) overlaps = overlaps.max(axis=1) labels = gt_boxes[gt_assignment, 4] @@ -465,8 +465,8 @@ def sample_rois_fpn(rois, overlaps = np.zeros((len(rois), )) labels = np.zeros((len(rois), )) else: - overlaps = bbox_overlaps(rois[:, 1:].astype(np.float), - gt_boxes[:, :4].astype(np.float)) + overlaps = bbox_overlaps(rois[:, 1:].astype(np.float32), + gt_boxes[:, :4].astype(np.float32)) gt_assignment = overlaps.argmax(axis=1) overlaps = overlaps.max(axis=1) labels = gt_boxes[gt_assignment, 4] @@ -617,8 +617,8 @@ def get_rois(rois, if labels is None: if len(gt_boxes) == 0: gt_boxes = np.array([[1, 1, 1, 1, 0]]) - overlaps = bbox_overlaps(rois[:, 1:].astype(np.float), - gt_boxes[:, :4].astype(np.float)) + overlaps = bbox_overlaps(rois[:, 1:].astype(np.float32), + gt_boxes[:, :4].astype(np.float32)) gt_assignment = overlaps.argmax(axis=1) overlaps = overlaps.max(axis=1) labels = gt_boxes[gt_assignment, 4] diff --git a/detection/retinaface/rcnn/io/rpn.py b/detection/retinaface/rcnn/io/rpn.py index 998fad8c8..1de0dc3f6 100644 --- a/detection/retinaface/rcnn/io/rpn.py +++ b/detection/retinaface/rcnn/io/rpn.py @@ -245,8 +245,8 @@ def _unmap(data, count, inds, fill=0): if gt_boxes.size > 0: # overlap between the anchors and the gt boxes # overlaps (ex, gt) - overlaps = bbox_overlaps(anchors.astype(np.float), - gt_boxes.astype(np.float)) + overlaps = bbox_overlaps(anchors.astype(np.float32), + gt_boxes.astype(np.float32)) argmax_overlaps = overlaps.argmax(axis=1) #print('AAA', argmax_overlaps.shape) max_overlaps = overlaps[np.arange(len(inds_inside)), argmax_overlaps] @@ -618,8 +618,8 @@ def assign_anchor_fpn(self, if gt_boxes.size > 0: # overlap between the anchors and the gt boxes # overlaps (ex, gt) - overlaps = bbox_overlaps(anchors.astype(np.float), - gt_boxes.astype(np.float)) + overlaps = bbox_overlaps(anchors.astype(np.float32), + gt_boxes.astype(np.float32)) argmax_overlaps = overlaps.argmax(axis=1) #print('AAA', argmax_overlaps.shape) max_overlaps = overlaps[np.arange(len(inds_inside)), diff --git a/detection/retinaface/rcnn/processing/bbox_regression.py b/detection/retinaface/rcnn/processing/bbox_regression.py index 0eaf917a6..f705b791b 100644 --- a/detection/retinaface/rcnn/processing/bbox_regression.py +++ b/detection/retinaface/rcnn/processing/bbox_regression.py @@ -24,7 +24,7 @@ def compute_bbox_regression_targets(rois, overlaps, labels): :return: targets[i][class, dx, dy, dw, dh] k * 5 """ # Ensure ROIs are floats - rois = rois.astype(np.float, copy=False) + rois = rois.astype(np.float32, copy=False) # Sanity check if len(rois) != len(overlaps): @@ -190,7 +190,7 @@ def compute_bbox_mask_targets_and_label(rois, overlaps, labels, seg, flipped): :return: targets[i][class, dx, dy, dw, dh] k * 5 """ # Ensure ROIs are floats - rois = rois.astype(np.float, copy=False) + rois = rois.astype(np.float32, copy=False) # Sanity check if len(rois) != len(overlaps): diff --git a/detection/retinaface/rcnn/processing/bbox_transform.py b/detection/retinaface/rcnn/processing/bbox_transform.py index 5ee3646ab..2dd5def4b 100644 --- a/detection/retinaface/rcnn/processing/bbox_transform.py +++ b/detection/retinaface/rcnn/processing/bbox_transform.py @@ -16,7 +16,7 @@ def bbox_overlaps_py(boxes, query_boxes): """ n_ = boxes.shape[0] k_ = query_boxes.shape[0] - overlaps = np.zeros((n_, k_), dtype=np.float) + overlaps = np.zeros((n_, k_), dtype=np.float32) for k in range(k_): query_box_area = (query_boxes[k, 2] - query_boxes[k, 0] + 1) * (query_boxes[k, 3] - query_boxes[k, 1] + 1) @@ -129,7 +129,7 @@ def nonlinear_pred(boxes, box_deltas): if boxes.shape[0] == 0: return np.zeros((0, box_deltas.shape[1])) - boxes = boxes.astype(np.float, copy=False) + boxes = boxes.astype(np.float32, copy=False) widths = boxes[:, 2] - boxes[:, 0] + 1.0 heights = boxes[:, 3] - boxes[:, 1] + 1.0 ctr_x = boxes[:, 0] + 0.5 * (widths - 1.0) @@ -161,7 +161,7 @@ def nonlinear_pred(boxes, box_deltas): def landmark_pred(boxes, landmark_deltas): if boxes.shape[0] == 0: return np.zeros((0, landmark_deltas.shape[1])) - boxes = boxes.astype(np.float, copy=False) + boxes = boxes.astype(np.float32, copy=False) widths = boxes[:, 2] - boxes[:, 0] + 1.0 heights = boxes[:, 3] - boxes[:, 1] + 1.0 ctr_x = boxes[:, 0] + 0.5 * (widths - 1.0) @@ -194,7 +194,7 @@ def iou_pred(boxes, box_deltas): if boxes.shape[0] == 0: return np.zeros((0, box_deltas.shape[1])) - boxes = boxes.astype(np.float, copy=False) + boxes = boxes.astype(np.float32, copy=False) x1 = boxes[:, 0] y1 = boxes[:, 1] x2 = boxes[:, 2] diff --git a/detection/retinaface/rcnn/pycocotools/cocoeval.py b/detection/retinaface/rcnn/pycocotools/cocoeval.py index 1d3531847..fcee91ab2 100644 --- a/detection/retinaface/rcnn/pycocotools/cocoeval.py +++ b/detection/retinaface/rcnn/pycocotools/cocoeval.py @@ -402,8 +402,8 @@ def accumulate(self, p=None): fps = np.logical_and(np.logical_not(dtm), np.logical_not(dtIg)) - tp_sum = np.cumsum(tps, axis=1).astype(dtype=np.float) - fp_sum = np.cumsum(fps, axis=1).astype(dtype=np.float) + tp_sum = np.cumsum(tps, axis=1).astype(dtype=np.float32) + fp_sum = np.cumsum(fps, axis=1).astype(dtype=np.float32) for t, (tp, fp) in enumerate(zip(tp_sum, fp_sum)): tp = np.array(tp) fp = np.array(fp) diff --git a/detection/retinaface/retinaface.py b/detection/retinaface/retinaface.py index 5b274e3da..edf9fb31f 100644 --- a/detection/retinaface/retinaface.py +++ b/detection/retinaface/retinaface.py @@ -735,7 +735,7 @@ def bbox_pred(boxes, box_deltas): if boxes.shape[0] == 0: return np.zeros((0, box_deltas.shape[1])) - boxes = boxes.astype(np.float, copy=False) + boxes = boxes.astype(np.float32, copy=False) widths = boxes[:, 2] - boxes[:, 0] + 1.0 heights = boxes[:, 3] - boxes[:, 1] + 1.0 ctr_x = boxes[:, 0] + 0.5 * (widths - 1.0) @@ -770,7 +770,7 @@ def bbox_pred(boxes, box_deltas): def landmark_pred(boxes, landmark_deltas): if boxes.shape[0] == 0: return np.zeros((0, landmark_deltas.shape[1])) - boxes = boxes.astype(np.float, copy=False) + boxes = boxes.astype(np.float32, copy=False) widths = boxes[:, 2] - boxes[:, 0] + 1.0 heights = boxes[:, 3] - boxes[:, 1] + 1.0 ctr_x = boxes[:, 0] + 0.5 * (widths - 1.0) diff --git a/detection/retinaface/test.py b/detection/retinaface/test.py index b88c82ba6..2fec9eb15 100644 --- a/detection/retinaface/test.py +++ b/detection/retinaface/test.py @@ -44,12 +44,12 @@ print('find', faces.shape[0], 'faces') for i in range(faces.shape[0]): #print('score', faces[i][4]) - box = faces[i].astype(np.int) + box = faces[i].astype(np.int32) #color = (255,0,0) color = (0, 0, 255) cv2.rectangle(img, (box[0], box[1]), (box[2], box[3]), color, 2) if landmarks is not None: - landmark5 = landmarks[i].astype(np.int) + landmark5 = landmarks[i].astype(np.int32) #print(landmark.shape) for l in range(landmark5.shape[0]): color = (0, 0, 255) diff --git a/detection/retinaface/test_widerface.py b/detection/retinaface/test_widerface.py index 78c2f83d9..572491aa7 100644 --- a/detection/retinaface/test_widerface.py +++ b/detection/retinaface/test_widerface.py @@ -128,7 +128,7 @@ def get_boxes(roi, pyramid): font = cv2.FONT_HERSHEY_SIMPLEX for i in range(boxes.shape[0]): box = boxes[i] - ibox = box[0:4].copy().astype(np.int) + ibox = box[0:4].copy().astype(np.int32) cv2.rectangle(im, (ibox[0], ibox[1]), (ibox[2], ibox[3]), (255, 0, 0), 2) #print('box', ibox) @@ -191,8 +191,8 @@ def test(args): 1) * (gt_boxes[:, 3] - gt_boxes[:, 1] + 1) num_pos += gt_boxes.shape[0] - overlaps = bbox_overlaps(boxes.astype(np.float), - gt_boxes.astype(np.float)) + overlaps = bbox_overlaps(boxes.astype(np.float32), + gt_boxes.astype(np.float32)) #print(im_info, gt_boxes.shape, boxes.shape, overlaps.shape, file=sys.stderr) _gt_overlaps = np.zeros((gt_boxes.shape[0])) diff --git a/detection/retinaface_anticov/rcnn/processing/bbox_regression.py b/detection/retinaface_anticov/rcnn/processing/bbox_regression.py index 0eaf917a6..f705b791b 100644 --- a/detection/retinaface_anticov/rcnn/processing/bbox_regression.py +++ b/detection/retinaface_anticov/rcnn/processing/bbox_regression.py @@ -24,7 +24,7 @@ def compute_bbox_regression_targets(rois, overlaps, labels): :return: targets[i][class, dx, dy, dw, dh] k * 5 """ # Ensure ROIs are floats - rois = rois.astype(np.float, copy=False) + rois = rois.astype(np.float32, copy=False) # Sanity check if len(rois) != len(overlaps): @@ -190,7 +190,7 @@ def compute_bbox_mask_targets_and_label(rois, overlaps, labels, seg, flipped): :return: targets[i][class, dx, dy, dw, dh] k * 5 """ # Ensure ROIs are floats - rois = rois.astype(np.float, copy=False) + rois = rois.astype(np.float32, copy=False) # Sanity check if len(rois) != len(overlaps): diff --git a/detection/retinaface_anticov/rcnn/processing/bbox_transform.py b/detection/retinaface_anticov/rcnn/processing/bbox_transform.py index 5ee3646ab..2dd5def4b 100644 --- a/detection/retinaface_anticov/rcnn/processing/bbox_transform.py +++ b/detection/retinaface_anticov/rcnn/processing/bbox_transform.py @@ -16,7 +16,7 @@ def bbox_overlaps_py(boxes, query_boxes): """ n_ = boxes.shape[0] k_ = query_boxes.shape[0] - overlaps = np.zeros((n_, k_), dtype=np.float) + overlaps = np.zeros((n_, k_), dtype=np.float32) for k in range(k_): query_box_area = (query_boxes[k, 2] - query_boxes[k, 0] + 1) * (query_boxes[k, 3] - query_boxes[k, 1] + 1) @@ -129,7 +129,7 @@ def nonlinear_pred(boxes, box_deltas): if boxes.shape[0] == 0: return np.zeros((0, box_deltas.shape[1])) - boxes = boxes.astype(np.float, copy=False) + boxes = boxes.astype(np.float32, copy=False) widths = boxes[:, 2] - boxes[:, 0] + 1.0 heights = boxes[:, 3] - boxes[:, 1] + 1.0 ctr_x = boxes[:, 0] + 0.5 * (widths - 1.0) @@ -161,7 +161,7 @@ def nonlinear_pred(boxes, box_deltas): def landmark_pred(boxes, landmark_deltas): if boxes.shape[0] == 0: return np.zeros((0, landmark_deltas.shape[1])) - boxes = boxes.astype(np.float, copy=False) + boxes = boxes.astype(np.float32, copy=False) widths = boxes[:, 2] - boxes[:, 0] + 1.0 heights = boxes[:, 3] - boxes[:, 1] + 1.0 ctr_x = boxes[:, 0] + 0.5 * (widths - 1.0) @@ -194,7 +194,7 @@ def iou_pred(boxes, box_deltas): if boxes.shape[0] == 0: return np.zeros((0, box_deltas.shape[1])) - boxes = boxes.astype(np.float, copy=False) + boxes = boxes.astype(np.float32, copy=False) x1 = boxes[:, 0] y1 = boxes[:, 1] x2 = boxes[:, 2] diff --git a/detection/retinaface_anticov/rcnn/processing/bbox_transform.py.orig b/detection/retinaface_anticov/rcnn/processing/bbox_transform.py.orig index ce3ab5962..c55f01939 100644 --- a/detection/retinaface_anticov/rcnn/processing/bbox_transform.py.orig +++ b/detection/retinaface_anticov/rcnn/processing/bbox_transform.py.orig @@ -19,7 +19,7 @@ def bbox_overlaps_py(boxes, query_boxes): """ n_ = boxes.shape[0] k_ = query_boxes.shape[0] - overlaps = np.zeros((n_, k_), dtype=np.float) + overlaps = np.zeros((n_, k_), dtype=np.float32) for k in range(k_): query_box_area = (query_boxes[k, 2] - query_boxes[k, 0] + 1) * (query_boxes[k, 3] - query_boxes[k, 1] + 1) for n in range(n_): @@ -171,7 +171,7 @@ def nonlinear_pred(boxes, box_deltas): if boxes.shape[0] == 0: return np.zeros((0, box_deltas.shape[1])) - boxes = boxes.astype(np.float, copy=False) + boxes = boxes.astype(np.float32, copy=False) widths = boxes[:, 2] - boxes[:, 0] + 1.0 heights = boxes[:, 3] - boxes[:, 1] + 1.0 ctr_x = boxes[:, 0] + 0.5 * (widths - 1.0) @@ -202,7 +202,7 @@ def nonlinear_pred(boxes, box_deltas): def landmark_pred(boxes, landmark_deltas): if boxes.shape[0] == 0: return np.zeros((0, landmark_deltas.shape[1])) - boxes = boxes.astype(np.float, copy=False) + boxes = boxes.astype(np.float32, copy=False) widths = boxes[:, 2] - boxes[:, 0] + 1.0 heights = boxes[:, 3] - boxes[:, 1] + 1.0 ctr_x = boxes[:, 0] + 0.5 * (widths - 1.0) @@ -236,7 +236,7 @@ def iou_pred(boxes, box_deltas): if boxes.shape[0] == 0: return np.zeros((0, box_deltas.shape[1])) - boxes = boxes.astype(np.float, copy=False) + boxes = boxes.astype(np.float32, copy=False) x1 = boxes[:, 0] y1 = boxes[:, 1] x2 = boxes[:, 2] diff --git a/detection/retinaface_anticov/retinaface_cov.py b/detection/retinaface_anticov/retinaface_cov.py index a4d1c1ac4..f4058b086 100644 --- a/detection/retinaface_anticov/retinaface_cov.py +++ b/detection/retinaface_anticov/retinaface_cov.py @@ -648,7 +648,7 @@ def bbox_pred(boxes, box_deltas): if boxes.shape[0] == 0: return np.zeros((0, box_deltas.shape[1])) - boxes = boxes.astype(np.float, copy=False) + boxes = boxes.astype(np.float32, copy=False) widths = boxes[:, 2] - boxes[:, 0] + 1.0 heights = boxes[:, 3] - boxes[:, 1] + 1.0 ctr_x = boxes[:, 0] + 0.5 * (widths - 1.0) @@ -683,7 +683,7 @@ def bbox_pred(boxes, box_deltas): def landmark_pred(boxes, landmark_deltas): if boxes.shape[0] == 0: return np.zeros((0, landmark_deltas.shape[1])) - boxes = boxes.astype(np.float, copy=False) + boxes = boxes.astype(np.float32, copy=False) widths = boxes[:, 2] - boxes[:, 0] + 1.0 heights = boxes[:, 3] - boxes[:, 1] + 1.0 ctr_x = boxes[:, 0] + 0.5 * (widths - 1.0) diff --git a/detection/retinaface_anticov/test.py b/detection/retinaface_anticov/test.py index f7c282b6d..8fb116296 100644 --- a/detection/retinaface_anticov/test.py +++ b/detection/retinaface_anticov/test.py @@ -46,7 +46,7 @@ for i in range(faces.shape[0]): #print('score', faces[i][4]) face = faces[i] - box = face[0:4].astype(np.int) + box = face[0:4].astype(np.int32) mask = face[5] print(i, box, mask) #color = (255,0,0) @@ -55,7 +55,7 @@ else: color = (0, 255, 0) cv2.rectangle(img, (box[0], box[1]), (box[2], box[3]), color, 2) - landmark5 = landmarks[i].astype(np.int) + landmark5 = landmarks[i].astype(np.int32) #print(landmark.shape) for l in range(landmark5.shape[0]): color = (255, 0, 0) diff --git a/detection/scrfd/mmdet/core/bbox/samplers/iou_balanced_neg_sampler.py b/detection/scrfd/mmdet/core/bbox/samplers/iou_balanced_neg_sampler.py index f275e430d..49819ca5a 100755 --- a/detection/scrfd/mmdet/core/bbox/samplers/iou_balanced_neg_sampler.py +++ b/detection/scrfd/mmdet/core/bbox/samplers/iou_balanced_neg_sampler.py @@ -72,7 +72,7 @@ def sample_via_interval(self, max_overlaps, full_set, num_expected): tmp_sampled_set = self.random_choice(tmp_inds, per_num_expected) else: - tmp_sampled_set = np.array(tmp_inds, dtype=np.int) + tmp_sampled_set = np.array(tmp_inds, dtype=np.int32) sampled_inds.append(tmp_sampled_set) sampled_inds = np.concatenate(sampled_inds) @@ -137,13 +137,13 @@ def _sample_neg(self, assign_result, num_expected, **kwargs): iou_sampling_neg_inds, num_expected_iou_sampling) else: iou_sampled_inds = np.array( - iou_sampling_neg_inds, dtype=np.int) + iou_sampling_neg_inds, dtype=np.int32) num_expected_floor = num_expected - len(iou_sampled_inds) if len(floor_neg_inds) > num_expected_floor: sampled_floor_inds = self.random_choice( floor_neg_inds, num_expected_floor) else: - sampled_floor_inds = np.array(floor_neg_inds, dtype=np.int) + sampled_floor_inds = np.array(floor_neg_inds, dtype=np.int32) sampled_inds = np.concatenate( (sampled_floor_inds, iou_sampled_inds)) if len(sampled_inds) < num_expected: diff --git a/detection/scrfd/mmdet/core/evaluation/widerface.py b/detection/scrfd/mmdet/core/evaluation/widerface.py index a1a3ad375..cbe87250e 100755 --- a/detection/scrfd/mmdet/core/evaluation/widerface.py +++ b/detection/scrfd/mmdet/core/evaluation/widerface.py @@ -52,7 +52,7 @@ def bbox_overlaps(boxes, query_boxes): n_ = boxes.shape[0] k_ = query_boxes.shape[0] - overlaps = np.zeros((n_, k_), dtype=np.float) + overlaps = np.zeros((n_, k_), dtype=np.float32) for k in range(k_): query_box_area = (query_boxes[k, 2] - query_boxes[k, 0] + 1) * (query_boxes[k, 3] - query_boxes[k, 1] + 1) @@ -317,7 +317,7 @@ def image_eval(pred, gt, ignore, iou_thresh, mpp): def img_pr_info(thresh_num, pred_info, proposal_list, pred_recall): pr_info = np.zeros((thresh_num, 2)).astype('float') - fp = np.zeros((pred_info.shape[0],), dtype=np.int) + fp = np.zeros((pred_info.shape[0],), dtype=np.int32) last_info = [-1, -1] for t in range(thresh_num): @@ -429,7 +429,7 @@ def wider_evaluation(pred, gt_path, iou_thresh=0.5, debug=False): #if len(keep_index) != 0: # ignore[keep_index-1] = 1 #assert len(keep_index)>0 - ignore = np.zeros(gt_boxes.shape[0], dtype=np.int) + ignore = np.zeros(gt_boxes.shape[0], dtype=np.int32) if len(keep_index) != 0: ignore[keep_index-1] = 1 pred_info = np_round(pred_info,1) @@ -523,7 +523,7 @@ def get_widerface_gts(gt_path): #if len(keep_index) != 0: # ignore[keep_index-1] = 1 #assert len(keep_index)>0 - #ignore = np.zeros(gt_boxes.shape[0], dtype=np.int) + #ignore = np.zeros(gt_boxes.shape[0], dtype=np.int32) #if len(keep_index) != 0: # ignore[keep_index-1] = 1 #print('ignore:', len(ignore), len(np.where(ignore==1)[0])) diff --git a/detection/scrfd/mmdet/datasets/custom.py b/detection/scrfd/mmdet/datasets/custom.py index 1f78a1f5a..24b73219c 100755 --- a/detection/scrfd/mmdet/datasets/custom.py +++ b/detection/scrfd/mmdet/datasets/custom.py @@ -139,7 +139,7 @@ def get_cat_ids(self, idx): list[int]: All categories in the image of specified index. """ - return self.data_infos[idx]['ann']['labels'].astype(np.int).tolist() + return self.data_infos[idx]['ann']['labels'].astype(np.int32).tolist() def pre_pipeline(self, results): """Prepare results dict for pipeline.""" diff --git a/detection/scrfd/mmdet/datasets/pipelines/transforms.py b/detection/scrfd/mmdet/datasets/pipelines/transforms.py index 869acfb5b..57ddc76d0 100755 --- a/detection/scrfd/mmdet/datasets/pipelines/transforms.py +++ b/detection/scrfd/mmdet/datasets/pipelines/transforms.py @@ -907,7 +907,7 @@ def __call__(self, results): top = random.randint(h - ch, 0) patch = np.array( - (int(left), int(top), int(left + cw), int(top + ch)), dtype=np.int) + (int(left), int(top), int(left + cw), int(top + ch)), dtype=np.int32) # center of boxes should inside the crop img # only adjust boxes and instance masks when the gt is not empty diff --git a/detection/scrfd/mmdet/models/roi_heads/bbox_heads/bbox_head.py b/detection/scrfd/mmdet/models/roi_heads/bbox_heads/bbox_head.py index e0931e176..2653429d2 100755 --- a/detection/scrfd/mmdet/models/roi_heads/bbox_heads/bbox_head.py +++ b/detection/scrfd/mmdet/models/roi_heads/bbox_heads/bbox_head.py @@ -262,7 +262,7 @@ def refine_bboxes(self, rois, labels, bbox_preds, pos_is_gts, img_metas): >>> labels = torch.randint(0, 2, (n_roi,)).long() >>> bbox_preds = random_boxes(n_roi, scale=scale, rng=rng) >>> # For each image, pretend random positive boxes are gts - >>> is_label_pos = (labels.numpy() > 0).astype(np.int) + >>> is_label_pos = (labels.numpy() > 0).astype(np.int32) >>> lbl_per_img = kwarray.group_items(is_label_pos, ... img_ids.numpy()) >>> pos_per_img = [sum(lbl_per_img.get(gid, [])) diff --git a/detection/scrfd/tools/scrfd.py b/detection/scrfd/tools/scrfd.py index 176d90e9d..d8d825e45 100644 --- a/detection/scrfd/tools/scrfd.py +++ b/detection/scrfd/tools/scrfd.py @@ -324,12 +324,12 @@ def scrfd_2p5gkps(**kwargs): print(kpss.shape) for i in range(bboxes.shape[0]): bbox = bboxes[i] - x1,y1,x2,y2,score = bbox.astype(np.int) + x1,y1,x2,y2,score = bbox.astype(np.int32) cv2.rectangle(img, (x1,y1) , (x2,y2) , (255,0,0) , 2) if kpss is not None: kps = kpss[i] for kp in kps: - kp = kp.astype(np.int) + kp = kp.astype(np.int32) cv2.circle(img, tuple(kp) , 1, (0,0,255) , 2) filename = img_path.split('/')[-1] print('output:', filename) diff --git a/parsing/dml_csr/loss/criterion.py b/parsing/dml_csr/loss/criterion.py index 9fa1bdc65..5790c1a21 100644 --- a/parsing/dml_csr/loss/criterion.py +++ b/parsing/dml_csr/loss/criterion.py @@ -49,8 +49,8 @@ def forward(self, preds, target, cycle_n=None): # binary edge input_binary_labels = target[1].data.cpu().numpy().astype(np.int64) - binary_pos_num = np.sum(input_binary_labels==1).astype(np.float) - binary_neg_num = np.sum(input_binary_labels==0).astype(np.float) + binary_pos_num = np.sum(input_binary_labels==1).astype(np.float32) + binary_neg_num = np.sum(input_binary_labels==0).astype(np.float32) binary_weight_pos = binary_neg_num/(binary_pos_num + binary_neg_num) binary_weight_neg = binary_pos_num/(binary_pos_num + binary_neg_num) @@ -67,11 +67,11 @@ def forward(self, preds, target, cycle_n=None): # semantic edge input_semantic_labels = target[2].data.cpu().numpy().astype(np.int64) semantic_weights = [] - semantic_pos_num = np.sum(input_semantic_labels>0).astype(np.float) - semantic_neg_num = np.sum(input_semantic_labels==0).astype(np.float) + semantic_pos_num = np.sum(input_semantic_labels>0).astype(np.float32) + semantic_neg_num = np.sum(input_semantic_labels==0).astype(np.float32) for lbl in range(self.num_classes): - lbl_num = np.sum(input_semantic_labels==lbl).astype(np.float) + lbl_num = np.sum(input_semantic_labels==lbl).astype(np.float32) weight_lbl = lbl_num/(semantic_pos_num + semantic_neg_num) semantic_weights.append(weight_lbl) semantic_weights = torch.from_numpy(np.array(semantic_weights)).float().cuda() diff --git a/python-package/insightface/model_zoo/scrfd.py b/python-package/insightface/model_zoo/scrfd.py index 674db4bba..541c31e2f 100644 --- a/python-package/insightface/model_zoo/scrfd.py +++ b/python-package/insightface/model_zoo/scrfd.py @@ -335,12 +335,12 @@ def scrfd_2p5gkps(**kwargs): print(kpss.shape) for i in range(bboxes.shape[0]): bbox = bboxes[i] - x1,y1,x2,y2,score = bbox.astype(np.int) + x1,y1,x2,y2,score = bbox.astype(np.int32) cv2.rectangle(img, (x1,y1) , (x2,y2) , (255,0,0) , 2) if kpss is not None: kps = kpss[i] for kp in kps: - kp = kp.astype(np.int) + kp = kp.astype(np.int32) cv2.circle(img, tuple(kp) , 1, (0,0,255) , 2) filename = img_path.split('/')[-1] print('output:', filename) diff --git a/recognition/_evaluation_/ijb/ijb_11.py b/recognition/_evaluation_/ijb/ijb_11.py index 53b332697..988bf95c5 100644 --- a/recognition/_evaluation_/ijb/ijb_11.py +++ b/recognition/_evaluation_/ijb/ijb_11.py @@ -51,8 +51,8 @@ def read_template_media_list(path): #ijb_meta = np.loadtxt(path, dtype=str) ijb_meta = pd.read_csv(path, sep=' ', header=None).values - templates = ijb_meta[:, 1].astype(np.int) - medias = ijb_meta[:, 2].astype(np.int) + templates = ijb_meta[:, 1].astype(np.int32) + medias = ijb_meta[:, 2].astype(np.int32) return templates, medias @@ -63,10 +63,10 @@ def read_template_pair_list(path): #pairs = np.loadtxt(path, dtype=str) pairs = pd.read_csv(path, sep=' ', header=None).values #print(pairs.shape) - #print(pairs[:, 0].astype(np.int)) - t1 = pairs[:, 0].astype(np.int) - t2 = pairs[:, 1].astype(np.int) - label = pairs[:, 2].astype(np.int) + #print(pairs[:, 0].astype(np.int32)) + t1 = pairs[:, 0].astype(np.int32) + t2 = pairs[:, 1].astype(np.int32) + label = pairs[:, 2].astype(np.int32) return t1, t2, label diff --git a/recognition/_evaluation_/ijb/ijb_1n.py b/recognition/_evaluation_/ijb/ijb_1n.py index 85ea4051f..fcc39b018 100644 --- a/recognition/_evaluation_/ijb/ijb_1n.py +++ b/recognition/_evaluation_/ijb/ijb_1n.py @@ -22,23 +22,23 @@ def read_template_subject_id_list(path): ijb_meta = np.loadtxt(path, dtype=str, skiprows=1, delimiter=',') - templates = ijb_meta[:, 0].astype(np.int) - subject_ids = ijb_meta[:, 1].astype(np.int) + templates = ijb_meta[:, 0].astype(np.int32) + subject_ids = ijb_meta[:, 1].astype(np.int32) return templates, subject_ids def read_template_media_list(path): ijb_meta = np.loadtxt(path, dtype=str) - templates = ijb_meta[:, 1].astype(np.int) - medias = ijb_meta[:, 2].astype(np.int) + templates = ijb_meta[:, 1].astype(np.int32) + medias = ijb_meta[:, 2].astype(np.int32) return templates, medias def read_template_pair_list(path): pairs = np.loadtxt(path, dtype=str) - t1 = pairs[:, 0].astype(np.int) - t2 = pairs[:, 1].astype(np.int) - label = pairs[:, 2].astype(np.int) + t1 = pairs[:, 0].astype(np.int32) + t2 = pairs[:, 1].astype(np.int32) + label = pairs[:, 2].astype(np.int32) return t1, t2, label diff --git a/recognition/_evaluation_/ijb/ijb_onnx.py b/recognition/_evaluation_/ijb/ijb_onnx.py index eb2edbe83..b09f6d3a0 100644 --- a/recognition/_evaluation_/ijb/ijb_onnx.py +++ b/recognition/_evaluation_/ijb/ijb_onnx.py @@ -77,16 +77,16 @@ def batchify_fn(data): def read_template_media_list(path): ijb_meta = pd.read_csv(path, sep=' ', header=None).values - templates = ijb_meta[:, 1].astype(np.int) - medias = ijb_meta[:, 2].astype(np.int) + templates = ijb_meta[:, 1].astype(np.int32) + medias = ijb_meta[:, 2].astype(np.int32) return templates, medias def read_template_pair_list(path): pairs = pd.read_csv(path, sep=' ', header=None).values - t1 = pairs[:, 0].astype(np.int) - t2 = pairs[:, 1].astype(np.int) - label = pairs[:, 2].astype(np.int) + t1 = pairs[:, 0].astype(np.int32) + t2 = pairs[:, 1].astype(np.int32) + label = pairs[:, 2].astype(np.int32) return t1, t2, label diff --git a/recognition/arcface_oneflow/eval/onnx_ijbc.py b/recognition/arcface_oneflow/eval/onnx_ijbc.py index 0d07d8185..a14e31fa1 100644 --- a/recognition/arcface_oneflow/eval/onnx_ijbc.py +++ b/recognition/arcface_oneflow/eval/onnx_ijbc.py @@ -87,16 +87,16 @@ def batchify_fn(data): def read_template_media_list(path): ijb_meta = pd.read_csv(path, sep=" ", header=None).values - templates = ijb_meta[:, 1].astype(np.int) - medias = ijb_meta[:, 2].astype(np.int) + templates = ijb_meta[:, 1].astype(np.int32) + medias = ijb_meta[:, 2].astype(np.int32) return templates, medias def read_template_pair_list(path): pairs = pd.read_csv(path, sep=" ", header=None).values - t1 = pairs[:, 0].astype(np.int) - t2 = pairs[:, 1].astype(np.int) - label = pairs[:, 2].astype(np.int) + t1 = pairs[:, 0].astype(np.int32) + t2 = pairs[:, 1].astype(np.int32) + label = pairs[:, 2].astype(np.int32) return t1, t2, label diff --git a/recognition/arcface_torch/eval_ijbc.py b/recognition/arcface_torch/eval_ijbc.py index 9c5a650d4..2921ea765 100644 --- a/recognition/arcface_torch/eval_ijbc.py +++ b/recognition/arcface_torch/eval_ijbc.py @@ -120,8 +120,8 @@ def divideIntoNstrand(listTemp, n): def read_template_media_list(path): # ijb_meta = np.loadtxt(path, dtype=str) ijb_meta = pd.read_csv(path, sep=' ', header=None).values - templates = ijb_meta[:, 1].astype(np.int) - medias = ijb_meta[:, 2].astype(np.int) + templates = ijb_meta[:, 1].astype(np.int32) + medias = ijb_meta[:, 2].astype(np.int32) return templates, medias @@ -132,10 +132,10 @@ def read_template_pair_list(path): # pairs = np.loadtxt(path, dtype=str) pairs = pd.read_csv(path, sep=' ', header=None).values # print(pairs.shape) - # print(pairs[:, 0].astype(np.int)) - t1 = pairs[:, 0].astype(np.int) - t2 = pairs[:, 1].astype(np.int) - label = pairs[:, 2].astype(np.int) + # print(pairs[:, 0].astype(np.int32)) + t1 = pairs[:, 0].astype(np.int32) + t2 = pairs[:, 1].astype(np.int32) + label = pairs[:, 2].astype(np.int32) return t1, t2, label diff --git a/recognition/arcface_torch/onnx_ijbc.py b/recognition/arcface_torch/onnx_ijbc.py index 31c491b1b..e228fdbdf 100644 --- a/recognition/arcface_torch/onnx_ijbc.py +++ b/recognition/arcface_torch/onnx_ijbc.py @@ -78,16 +78,16 @@ def collate_fn(data): def read_template_media_list(path): ijb_meta = pd.read_csv(path, sep=' ', header=None).values - templates = ijb_meta[:, 1].astype(np.int) - medias = ijb_meta[:, 2].astype(np.int) + templates = ijb_meta[:, 1].astype(np.int32) + medias = ijb_meta[:, 2].astype(np.int32) return templates, medias def read_template_pair_list(path): pairs = pd.read_csv(path, sep=' ', header=None).values - t1 = pairs[:, 0].astype(np.int) - t2 = pairs[:, 1].astype(np.int) - label = pairs[:, 2].astype(np.int) + t1 = pairs[:, 0].astype(np.int32) + t2 = pairs[:, 1].astype(np.int32) + label = pairs[:, 2].astype(np.int32) return t1, t2, label diff --git a/recognition/arcface_torch/torch2onnx.py b/recognition/arcface_torch/torch2onnx.py index f6055d1fe..f51dfabfe 100644 --- a/recognition/arcface_torch/torch2onnx.py +++ b/recognition/arcface_torch/torch2onnx.py @@ -6,7 +6,7 @@ def convert_onnx(net, path_module, output, opset=11, simplify=False): assert isinstance(net, torch.nn.Module) img = np.random.randint(0, 255, size=(112, 112, 3), dtype=np.int32) - img = img.astype(np.float) + img = img.astype(np.float32) img = (img / 255. - 0.5) / 0.5 # torch style norm img = img.transpose((2, 0, 1)) img = torch.from_numpy(img).unsqueeze(0).float() diff --git a/recognition/arcface_torch/utils/plot.py b/recognition/arcface_torch/utils/plot.py index 7f1d39da6..c1ad0f469 100644 --- a/recognition/arcface_torch/utils/plot.py +++ b/recognition/arcface_torch/utils/plot.py @@ -17,9 +17,9 @@ def read_template_pair_list(path): pairs = pd.read_csv(path, sep=' ', header=None).values - t1 = pairs[:, 0].astype(np.int) - t2 = pairs[:, 1].astype(np.int) - label = pairs[:, 2].astype(np.int) + t1 = pairs[:, 0].astype(np.int32) + t2 = pairs[:, 1].astype(np.int32) + label = pairs[:, 2].astype(np.int32) return t1, t2, label diff --git a/recognition/partial_fc/mxnet/evaluation/ijb.py b/recognition/partial_fc/mxnet/evaluation/ijb.py index ffcabd69e..4603edeec 100644 --- a/recognition/partial_fc/mxnet/evaluation/ijb.py +++ b/recognition/partial_fc/mxnet/evaluation/ijb.py @@ -162,16 +162,16 @@ def divideIntoNstrand(listTemp, n): def read_template_media_list(path): ijb_meta = pd.read_csv(path, sep=' ', header=None).values - templates = ijb_meta[:, 1].astype(np.int) - medias = ijb_meta[:, 2].astype(np.int) + templates = ijb_meta[:, 1].astype(np.int32) + medias = ijb_meta[:, 2].astype(np.int32) return templates, medias def read_template_pair_list(path): pairs = pd.read_csv(path, sep=' ', header=None).values - t1 = pairs[:, 0].astype(np.int) - t2 = pairs[:, 1].astype(np.int) - label = pairs[:, 2].astype(np.int) + t1 = pairs[:, 0].astype(np.int32) + t2 = pairs[:, 1].astype(np.int32) + label = pairs[:, 2].astype(np.int32) return t1, t2, label diff --git a/recognition/subcenter_arcface/drop.py b/recognition/subcenter_arcface/drop.py index 24d20bae8..106076f01 100644 --- a/recognition/subcenter_arcface/drop.py +++ b/recognition/subcenter_arcface/drop.py @@ -165,7 +165,7 @@ def main(args): x, _, contents = get_embedding(args, imgrec, id_item[1], id_item[2], image_size, model) subcenters = W[wid] - K_stat = np.zeros((K, ), dtype=np.int) + K_stat = np.zeros((K, ), dtype=np.int32) for i in range(x.shape[0]): _x = x[i] sim = np.dot(subcenters, _x) # len(sim)==K diff --git a/recognition/vpl/eval_ijbc.py b/recognition/vpl/eval_ijbc.py index c144e4e8e..2561c37ec 100644 --- a/recognition/vpl/eval_ijbc.py +++ b/recognition/vpl/eval_ijbc.py @@ -120,8 +120,8 @@ def divideIntoNstrand(listTemp, n): def read_template_media_list(path): # ijb_meta = np.loadtxt(path, dtype=str) ijb_meta = pd.read_csv(path, sep=' ', header=None).values - templates = ijb_meta[:, 1].astype(np.int) - medias = ijb_meta[:, 2].astype(np.int) + templates = ijb_meta[:, 1].astype(np.int32) + medias = ijb_meta[:, 2].astype(np.int32) return templates, medias @@ -132,10 +132,10 @@ def read_template_pair_list(path): # pairs = np.loadtxt(path, dtype=str) pairs = pd.read_csv(path, sep=' ', header=None).values # print(pairs.shape) - # print(pairs[:, 0].astype(np.int)) - t1 = pairs[:, 0].astype(np.int) - t2 = pairs[:, 1].astype(np.int) - label = pairs[:, 2].astype(np.int) + # print(pairs[:, 0].astype(np.int32)) + t1 = pairs[:, 0].astype(np.int32) + t2 = pairs[:, 1].astype(np.int32) + label = pairs[:, 2].astype(np.int32) return t1, t2, label diff --git a/recognition/vpl/onnx_ijbc.py b/recognition/vpl/onnx_ijbc.py index 05b50bfad..e6301855e 100644 --- a/recognition/vpl/onnx_ijbc.py +++ b/recognition/vpl/onnx_ijbc.py @@ -77,16 +77,16 @@ def batchify_fn(data): def read_template_media_list(path): ijb_meta = pd.read_csv(path, sep=' ', header=None).values - templates = ijb_meta[:, 1].astype(np.int) - medias = ijb_meta[:, 2].astype(np.int) + templates = ijb_meta[:, 1].astype(np.int32) + medias = ijb_meta[:, 2].astype(np.int32) return templates, medias def read_template_pair_list(path): pairs = pd.read_csv(path, sep=' ', header=None).values - t1 = pairs[:, 0].astype(np.int) - t2 = pairs[:, 1].astype(np.int) - label = pairs[:, 2].astype(np.int) + t1 = pairs[:, 0].astype(np.int32) + t2 = pairs[:, 1].astype(np.int32) + label = pairs[:, 2].astype(np.int32) return t1, t2, label diff --git a/recognition/vpl/torch2onnx.py b/recognition/vpl/torch2onnx.py index 4e7a68e68..f1703021e 100644 --- a/recognition/vpl/torch2onnx.py +++ b/recognition/vpl/torch2onnx.py @@ -6,7 +6,7 @@ def convert_onnx(net, path_module, output, opset=11, simplify=False): assert isinstance(net, torch.nn.Module) img = np.random.randint(0, 255, size=(112, 112, 3), dtype=np.int32) - img = img.astype(np.float) + img = img.astype(np.float32) img = (img / 255. - 0.5) / 0.5 # torch style norm img = img.transpose((2, 0, 1)) img = torch.from_numpy(img).unsqueeze(0).float() diff --git a/recognition/vpl/utils/plot.py b/recognition/vpl/utils/plot.py index ccc588e5c..022060d3e 100644 --- a/recognition/vpl/utils/plot.py +++ b/recognition/vpl/utils/plot.py @@ -18,9 +18,9 @@ def read_template_pair_list(path): pairs = pd.read_csv(path, sep=' ', header=None).values - t1 = pairs[:, 0].astype(np.int) - t2 = pairs[:, 1].astype(np.int) - label = pairs[:, 2].astype(np.int) + t1 = pairs[:, 0].astype(np.int32) + t2 = pairs[:, 1].astype(np.int32) + label = pairs[:, 2].astype(np.int32) return t1, t2, label diff --git a/reconstruction/PBIDR/code/utils/plots.py b/reconstruction/PBIDR/code/utils/plots.py index fde881e5b..14e949eb9 100644 --- a/reconstruction/PBIDR/code/utils/plots.py +++ b/reconstruction/PBIDR/code/utils/plots.py @@ -231,7 +231,7 @@ def get_surface_high_res_mesh(sdf, resolution=100): # return mesh_low_res components = mesh_low_res.split(only_watertight=False) - areas = np.array([c.area for c in components], dtype=np.float) + areas = np.array([c.area for c in components], dtype=np.float32) mesh_low_res = components[areas.argmax()] recon_pc = trimesh.sample.sample_surface(mesh_low_res, 10000)[0] diff --git a/reconstruction/gaze/datasets/augs.py b/reconstruction/gaze/datasets/augs.py index 1e701d9fa..2551d1edf 100644 --- a/reconstruction/gaze/datasets/augs.py +++ b/reconstruction/gaze/datasets/augs.py @@ -24,7 +24,7 @@ def apply(self, image, border_size_limit, **params): border_size[2] *= image.shape[1] border_size[1] *= image.shape[0] border_size[3] *= image.shape[0] - border_size = border_size.astype(np.int) + border_size = border_size.astype(np.int32) image[:,:border_size[0],:] = self.fill_value image[:border_size[1],:,:] = self.fill_value image[:,border_size[2]:,:] = self.fill_value diff --git a/reconstruction/gaze/test_gaze.py b/reconstruction/gaze/test_gaze.py index a4ebc9fa3..857510e53 100644 --- a/reconstruction/gaze/test_gaze.py +++ b/reconstruction/gaze/test_gaze.py @@ -87,7 +87,7 @@ def draw_item(self, eimg, item): #trf_crp.pseudoinverse().apply(PointCloud(eye_r[iris_idx_481]).with_dims([0, 1])).view(1) for _eye in [eye_l, eye_r]: - _kps = _eye[self.iris_idx_481,:].astype(np.int) + _kps = _eye[self.iris_idx_481,:].astype(np.int32) for l in range(_kps.shape[0]): color = (0, 255, 0) cv2.circle(eimg, (_kps[l][1], _kps[l][0]), 4, color, 4) @@ -97,8 +97,8 @@ def draw_item(self, eimg, item): for k in range(3): ix = _tri[k] iy = _tri[(k+1)%3] - x = _eye[ix,:2].astype(np.int)[::-1] - y = _eye[iy,:2].astype(np.int)[::-1] + x = _eye[ix,:2].astype(np.int32)[::-1] + y = _eye[iy,:2].astype(np.int32)[::-1] cv2.line(eimg, x, y, color, 1) theta_x_l, theta_y_l, vec_l = angles_and_vec_from_eye(eye_l, self.iris_idx_481) @@ -126,8 +126,8 @@ def draw_item(self, eimg, item): y = x.copy() y[0] += dx y[1] += dy - x = x.astype(np.int) - y = y.astype(np.int) + x = x.astype(np.int32) + y = y.astype(np.int32) color = (0,255,255) cv2.line(eimg, x, y, color, 2) @@ -138,8 +138,8 @@ def draw_item(self, eimg, item): y = x.copy() y[0] += dx y[1] += dy - x = x.astype(np.int) - y = y.astype(np.int) + x = x.astype(np.int32) + y = y.astype(np.int32) color = (0,255,255) cv2.line(eimg, x, y, color, 2) return eimg diff --git a/reconstruction/jmlr/dataset.py b/reconstruction/jmlr/dataset.py index 5f82855f3..40a617a18 100644 --- a/reconstruction/jmlr/dataset.py +++ b/reconstruction/jmlr/dataset.py @@ -681,7 +681,7 @@ def test_dataset1(cfg): #img_local = (img_local+1.0) * 128.0 #draw = img_local.astype(np.uint8).transpose( (1,2,0) )[:,:,::-1].copy() #for i in range(points2d.shape[0]): - # pt = points2d[i].astype(np.int) + # pt = points2d[i].astype(np.int32) # cv2.circle(draw, pt, 2, (255,0,0), 2) ##output_path = "outputs/%d_%.3f_%.3f_%.3f.jpg"%(idx, label_6dof[0], label_6dof[1], label_6dof[2]) #output_path = "outputs/%06d.jpg"%(idx) @@ -787,10 +787,10 @@ def test_dataset2(cfg): img_local = (img_local+1.0) * 128.0 draw = img_local.astype(np.uint8).transpose( (1,2,0) )[:,:,::-1].copy() for i in range(points2d.shape[0]): - pt = points2d[i].astype(np.int) + pt = points2d[i].astype(np.int32) cv2.circle(draw, pt, 2, (255,0,0), 2) for i in range(eye_points.shape[0]): - pt = eye_points[i].astype(np.int) + pt = eye_points[i].astype(np.int32) cv2.circle(draw, pt, 2, (0,255,0), 2) ##output_path = "outputs/%d_%.3f_%.3f_%.3f.jpg"%(idx, label_6dof[0], label_6dof[1], label_6dof[2]) output_path = "outputs/%06d.jpg"%(idx) diff --git a/reconstruction/jmlr/utils/plot.py b/reconstruction/jmlr/utils/plot.py index ccc588e5c..022060d3e 100644 --- a/reconstruction/jmlr/utils/plot.py +++ b/reconstruction/jmlr/utils/plot.py @@ -18,9 +18,9 @@ def read_template_pair_list(path): pairs = pd.read_csv(path, sep=' ', header=None).values - t1 = pairs[:, 0].astype(np.int) - t2 = pairs[:, 1].astype(np.int) - label = pairs[:, 2].astype(np.int) + t1 = pairs[:, 0].astype(np.int32) + t2 = pairs[:, 1].astype(np.int32) + label = pairs[:, 2].astype(np.int32) return t1, t2, label diff --git a/reconstruction/ostec/core/operator.py b/reconstruction/ostec/core/operator.py index 7e988f84a..b26c09044 100644 --- a/reconstruction/ostec/core/operator.py +++ b/reconstruction/ostec/core/operator.py @@ -161,7 +161,7 @@ def create_syn(self, face, trg_angle=[0, 0, 0], include_mask=None): if include_mask is not None: fill_mask = fill_mask | include_mask.astype(np.bool) if face.exclude_mask is not None: - tcoord_sampling = np.round(self.tcoords.points[:,::-1] * face.exclude_mask.shape).astype(np.int) + tcoord_sampling = np.round(self.tcoords.points[:,::-1] * face.exclude_mask.shape).astype(np.int32) fill_mask[self.mask] = fill_mask[self.mask] & ~face.exclude_mask[face.exclude_mask.shape[0] - tcoord_sampling[:, 0], tcoord_sampling[:, 1]] mask_mesh = ColouredTriMesh(face.tmesh.points, trilist=face.tmesh.trilist, colours=np.tile(fill_mask, [3, 1]).T) @@ -362,7 +362,7 @@ def run(self, im, reconstruction_dict, face_mask=None): angle_uv_list = [np.clip(angle_uv_src.pixels * face.coef_dict()['src'],-1,1)] view_angle_src_full = self.camera_tri_angle_src(face.tmesh_rotated) - tcoord_sampling = np.round(self.tcoords.points*angle_uv_src.shape).astype(np.int) + tcoord_sampling = np.round(self.tcoords.points*angle_uv_src.shape).astype(np.int32) view_angle_src_full[self.mask] = angle_uv_src.pixels[0, angle_uv_src.shape[0] - tcoord_sampling[:, 1], tcoord_sampling[:, 0]] view_angle_src_full[~self.tight_mask] = -1 # Only take tight crop from the original image @@ -399,7 +399,7 @@ def run(self, im, reconstruction_dict, face_mask=None): uv_blending = {} for i, key in enumerate(key_list): - uv_blending[key] = np.zeros(max_ind_one_hot[:,i].shape,np.float) + uv_blending[key] = np.zeros(max_ind_one_hot[:,i].shape,np.float32) for j in range(i): uv_blending[key] += max_ind_one_hot[:,j] uv_blending[key] = np.clip(uv_blending[key],0, 1) diff --git a/reconstruction/ostec/external/landmark_detector/utils.py b/reconstruction/ostec/external/landmark_detector/utils.py index 93a3e9c5b..229fa0f29 100644 --- a/reconstruction/ostec/external/landmark_detector/utils.py +++ b/reconstruction/ostec/external/landmark_detector/utils.py @@ -411,7 +411,7 @@ def crop_image(img, center, scale, res, base=384): # Upper left point ul = np.floor(t.apply([0,0])) # Bottom right point - br = np.ceil(t.apply(res).astype(np.int)) + br = np.ceil(t.apply(res).astype(np.int32)) # crop and rescale diff --git a/reconstruction/ostec/utils/align2stylegan.py b/reconstruction/ostec/utils/align2stylegan.py index 9c45953ea..3f064b195 100644 --- a/reconstruction/ostec/utils/align2stylegan.py +++ b/reconstruction/ostec/utils/align2stylegan.py @@ -24,7 +24,7 @@ def create_perspective_transform_matrix(src, dst): [0, 0, 0, x, y, 1, -Y * x, -Y * y], ]) - A = np.matrix(in_matrix, dtype=np.float) + A = np.matrix(in_matrix, dtype=np.float32) B = np.array(dst).reshape(8) af = np.dot(np.linalg.inv(A.T * A) * A.T, B) return np.append(np.array(af).reshape(8), 1).reshape((3, 3)) @@ -80,7 +80,7 @@ def create_perspective_transform(src, dst, round=False, splat_args=False): transform_matrix = create_perspective_transform_matrix(src, dst) error = None except np.linalg.LinAlgError as e: - transform_matrix = np.identity(3, dtype=np.float) + transform_matrix = np.identity(3, dtype=np.float32) error = "invalid input quads (%s and %s): %s" %(src, dst, e) error = error.replace("\n", "") diff --git a/reconstruction/ostec/utils/utils.py b/reconstruction/ostec/utils/utils.py index 6eb00eb33..36d049ac9 100644 --- a/reconstruction/ostec/utils/utils.py +++ b/reconstruction/ostec/utils/utils.py @@ -109,7 +109,7 @@ def uv_stiching(img_uv_list, angle_uv_list, smoothing_sigma = 10, seamless_clone im_clone = cv.seamlessClone(dst, mixed, mask_inv, (512,512), cv.NORMAL_CLONE) dst = (im_clone * (1-mask_g/255) + dst* (mask_g/255)).astype(np.uint8) - final_uv = Image(np.transpose(dst.astype(np.float)/255,[2,0,1])) + final_uv = Image(np.transpose(dst.astype(np.float32)/255,[2,0,1])) else: final_uv = Image(np.sum(all_uvs * max_ind_one_hot_g, axis=0)) @@ -120,7 +120,7 @@ def im_menpo2PIL(menpo_im): return PIL.Image.fromarray((menpo_im.pixels_with_channels_at_back() * 255).astype(np.uint8)) def im_PIL2menpo(pil_im): - return Image.init_from_channels_at_back(np.array(pil_im).astype(np.float) / 255) + return Image.init_from_channels_at_back(np.array(pil_im).astype(np.float32) / 255) def fill_UV(UV): mask = np.sum(UV.pixels, 0) == 0