Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion alignment/coordinate_reg/image_infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion alignment/heatmap/metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion alignment/synthetics/datasets/augs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions alignment/synthetics/test_synthetics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions alignment/synthetics/tools/prepare_synthetics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions detection/retinaface/rcnn/PY_OP/cascade_refine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion detection/retinaface/rcnn/core/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions detection/retinaface/rcnn/core/tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
Expand Down
2 changes: 1 addition & 1 deletion detection/retinaface/rcnn/dataset/ds_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
8 changes: 4 additions & 4 deletions detection/retinaface/rcnn/dataset/imdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions detection/retinaface/rcnn/io/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand All @@ -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 = []
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
16 changes: 8 additions & 8 deletions detection/retinaface/rcnn/io/rcnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down
8 changes: 4 additions & 4 deletions detection/retinaface/rcnn/io/rpn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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)),
Expand Down
4 changes: 2 additions & 2 deletions detection/retinaface/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions detection/retinaface/test_widerface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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]))
Expand Down
4 changes: 2 additions & 2 deletions detection/retinaface_anticov/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion detection/scrfd/mmdet/datasets/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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, []))
Expand Down
4 changes: 2 additions & 2 deletions detection/scrfd/tools/scrfd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions examples/person_detection/scrfd_person.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading