Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update scrfd_person.py - numpy int (deprecated) #2592

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions body/human_pose/ambiguity_aware/scripts/eval_lsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@
else:
color = "darkorange"
cv_color = (89, 141, 252)
x1, y1 = joints_2d[i].astype(np.int)
x2, y2 = joints_2d[j].astype(np.int)
x1, y1 = joints_2d[i].astype(np.int32)
x2, y2 = joints_2d[j].astype(np.int32)

cv2.line(image, (x1, y1), (x2, y2), cv_color, 2)
x1, y1, z1 = joints_3d_pre[i]
x2, y2, z2 = joints_3d_pre[j]
ax.plot([z1, z2], [x1, x2], [-y1, -y2], c=color, linewidth=3)

image = image[::-1, :, ::-1].copy().astype(np.float) / 255.
image = image[::-1, :, ::-1].copy().astype(np.float32) / 255.
r = 0.95
xroot = yroot = zroot = 0.
# radius = max(4, (np.mean(image.shape[:2]) * 0.01).astype(int))
Expand Down
6 changes: 3 additions & 3 deletions body/human_pose/ambiguity_aware/scripts/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@
else:
color = "darkorange"
cv_color = (89, 141, 252)
x1, y1 = joints_2d[i].astype(np.int)
x2, y2 = joints_2d[j].astype(np.int)
x1, y1 = joints_2d[i].astype(np.int32)
x2, y2 = joints_2d[j].astype(np.int32)

cv2.line(image, (x1, y1), (x2, y2), cv_color, 2)
x1, y1, z1 = joints_3d_pre[i]
x2, y2, z2 = joints_3d_pre[j]
ax.plot([z1, z2], [x1, x2], [-y1, -y2], c=color, linewidth=3)

image = image[::-1, :, ::-1].copy().astype(np.float) / 255.
image = image[::-1, :, ::-1].copy().astype(np.float32) / 255.
r = 0.95
xroot = yroot = zroot = 0.
# radius = max(4, (np.mean(image.shape[:2]) * 0.01).astype(int))
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/cython/bbox.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions detection/retinaface/rcnn/cython/cpu_nms.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion detection/retinaface/rcnn/cython/gpu_nms.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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]
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
12 changes: 6 additions & 6 deletions detection/retinaface/rcnn/dataset/retinaface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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))
Expand Down
24 changes: 12 additions & 12 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 @@ -215,15 +215,15 @@ 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]
new_rec['boxes'][:, 0] -= left
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
Loading