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/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/io/image.py b/detection/retinaface/rcnn/io/image.py index 0296fb4de..05eb3bcb2 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] @@ -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/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/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/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/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/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() 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/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/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..f4c160f91 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 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/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