Skip to content

Commit 3422a52

Browse files
committed
replace deprecated numpy dtypes
1 parent c166973 commit 3422a52

File tree

20 files changed

+63
-58
lines changed

20 files changed

+63
-58
lines changed

demos/3d_segmentation_demo/python/3d_segmentation_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def read_image(test_data_path, data_name, sizes=(128, 128, 128), is_series=True,
214214

215215
bbox_min = np.min(bboxes[:, 0, :], axis=0).ravel().astype(int)
216216
bbox_max = np.max(bboxes[:, 1, :], axis=0).ravel().astype(int)
217-
bbox = np.zeros(shape=(2, 3), dtype=np.float)
217+
bbox = np.zeros(shape=(2, 3), dtype=float)
218218
bbox[0] = bbox_min
219219
bbox[1] = bbox_max
220220

demos/common/python/openvino/model_zoo/model_api/models/centernet.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ def _topk(scores, K=40):
132132
topk_inds = np.argpartition(scores, -K, axis=1)[:, -K:]
133133
topk_scores = scores[np.arange(scores.shape[0])[:, None], topk_inds]
134134

135-
topk_ys = (topk_inds / width).astype(np.int32).astype(np.float)
136-
topk_xs = (topk_inds % width).astype(np.int32).astype(np.float)
135+
topk_ys = (topk_inds / width).astype(np.int32).astype(float)
136+
topk_xs = (topk_inds % width).astype(np.int32).astype(float)
137137

138138
topk_scores = topk_scores.reshape((-1))
139139
topk_ind = np.argpartition(topk_scores, -K)[-K:]

demos/common/python/openvino/model_zoo/model_api/models/ctpn.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ def build_graph(self, text_proposals, scores, im_size):
326326
boxes_table[int(box[0])].append(index)
327327
self.boxes_table = boxes_table
328328

329-
graph = np.zeros((text_proposals.shape[0], text_proposals.shape[0]), np.bool)
329+
graph = np.zeros((text_proposals.shape[0], text_proposals.shape[0]), bool)
330330

331331
for index, box in enumerate(text_proposals):
332332
successions = self.get_successions(index)
@@ -379,7 +379,7 @@ def fit_y(x, y, x1, x2):
379379
text_lines[:, :4].clip(min=0, max=(image_size[1] - 1, image_size[0] - 1, image_size[1] - 1, image_size[0] - 1),
380380
out=text_lines[:, :4])
381381

382-
text_recs = np.zeros((len(text_lines), 9), np.float)
382+
text_recs = np.zeros((len(text_lines), 9), float)
383383
for index, line in enumerate(text_lines):
384384
xmin, ymin, xmax, ymax = line[0], line[1], line[2], line[3]
385385
text_recs[index, 0], text_recs[index, 1], text_recs[index, 2], text_recs[index, 3] = xmin, ymin, xmax, ymin

demos/common/python/openvino/model_zoo/model_api/models/retinaface.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ def bbox_pred(boxes, box_deltas):
265265
if boxes.shape[0] == 0:
266266
return np.zeros((0, box_deltas.shape[1]))
267267

268-
boxes = boxes.astype(np.float, copy=False)
268+
boxes = boxes.astype(float, copy=False)
269269
widths = boxes[:, 2] - boxes[:, 0] + 1.0
270270
heights = boxes[:, 3] - boxes[:, 1] + 1.0
271271
ctr_x = boxes[:, 0] + 0.5 * (widths - 1.0)
@@ -309,7 +309,7 @@ def anchors_plane(height, width, stride, base_anchors):
309309
def landmark_pred(boxes, landmark_deltas):
310310
if boxes.shape[0] == 0:
311311
return np.zeros((0, landmark_deltas.shape[1]))
312-
boxes = boxes.astype(np.float, copy=False)
312+
boxes = boxes.astype(float, copy=False)
313313
widths = boxes[:, 2] - boxes[:, 0] + 1.0
314314
heights = boxes[:, 3] - boxes[:, 1] + 1.0
315315
ctr_x = boxes[:, 0] + 0.5 * (widths - 1.0)

demos/face_recognition_demo/python/face_identifier.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def _align_rois(self, face_images, face_landmarks):
136136

137137
for image, image_landmarks in zip(face_images, face_landmarks):
138138
scale = np.array((image.shape[1], image.shape[0]))
139-
desired_landmarks = np.array(self.REFERENCE_LANDMARKS, dtype=np.float64) * scale
139+
desired_landmarks = np.array(self.REFERENCE_LANDMARKS, dtype=float) * scale
140140
landmarks = image_landmarks * scale
141141

142142
transform = FaceIdentifier.get_transform(desired_landmarks, landmarks)

demos/smart_classroom_demo/utils/action_event_metrics.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def match_detections(predicted_data, gt_data, min_iou):
166166
sorted_predicted_bboxes.sort(key=lambda tup: tup[1].det_conf, reverse=True)
167167

168168
matches = []
169-
visited_gt = np.zeros(len(gt_bboxes), dtype=np.bool)
169+
visited_gt = np.zeros(len(gt_bboxes), dtype=bool)
170170
for i in range(len(sorted_predicted_bboxes)):
171171
predicted_id = sorted_predicted_bboxes[i][0]
172172
predicted_bbox = sorted_predicted_bboxes[i][1]
@@ -453,8 +453,8 @@ def calculate_metrics(all_tracks):
453453
total_num_gt_events += len(gt_events)
454454

455455
if len(matches) > 0:
456-
matched_gt = np.zeros([len(gt_events)], dtype=np.bool)
457-
matched_pred = np.zeros([len(pred_events)], dtype=np.bool)
456+
matched_gt = np.zeros([len(gt_events)], dtype=bool)
457+
matched_pred = np.zeros([len(pred_events)], dtype=bool)
458458
for match in matches:
459459
matched_gt[match[0]] = True
460460
matched_pred[match[1]] = True

demos/text_to_speech_demo/python/utils/wav_processing.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def pad_tensor(x, pad, side='both'):
2828
# i.e., it won't generalise to other shapes/dims
2929
b, t, c = x.shape
3030
total = t + 2 * pad if side == 'both' else t + pad
31-
padded = np.zeros((b, total, c), dtype=np.float)
31+
padded = np.zeros((b, total, c), dtype=float)
3232
if side in ('before', 'both'):
3333
padded[:, pad:pad + t, :] = x
3434
elif side == 'after':
@@ -94,7 +94,7 @@ def fold_with_overlap(x, target, overlap):
9494
padding = target + 2 * overlap - remaining
9595
x = pad_tensor(x, padding, side='after')
9696

97-
folded = np.zeros((num_folds, target + 2 * overlap, features), dtype=np.float)
97+
folded = np.zeros((num_folds, target + 2 * overlap, features), dtype=float)
9898

9999

100100
# Get the values for the folded tensor
@@ -113,13 +113,13 @@ def xfade_and_unfold(y, overlap):
113113
Args:
114114
y (ndarry) : Batched sequences of audio samples
115115
shape=(num_folds, target + 2 * overlap)
116-
dtype=np.float64
116+
dtype=float
117117
overlap (int) : Timesteps for both xfade and rnn warmup
118118
119119
Return:
120120
(ndarry) : audio samples in a 1d array
121121
shape=(total_len)
122-
dtype=np.float64
122+
dtype=float
123123
124124
Details:
125125
y = [[seq1],

models/public/quartznet-15x5-en/model.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ conversion_to_onnx_args:
101101
- --model-param=decoder_weights=r"$dl_dir/models/.nemo_tmp/JasperDecoderForCTC.pt"
102102
- --input-names=audio_signal
103103
- --output-names=output
104-
- '--conversion-param=dynamic_axes={"audio_signal": {0: "batch_size, 2: "wave_len"}, {"output: {0: "batch_size", 2: "wave_len"}}'
104+
- '--conversion-param=dynamic_axes={"audio_signal": {0: "batch_size", 2: "wave_len"}, {"output": {0: "batch_size", 2: "wave_len"}}'
105105
input_info:
106106
- name: audio_signal
107107
shape: [1, 64, 128]

tools/accuracy_checker/openvino/tools/accuracy_checker/adapters/ctpn.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ def build_graph(self, text_proposals, scores, im_size):
329329
boxes_table[int(box[0])].append(index)
330330
self.boxes_table = boxes_table
331331

332-
graph = np.zeros((text_proposals.shape[0], text_proposals.shape[0]), np.bool)
332+
graph = np.zeros((text_proposals.shape[0], text_proposals.shape[0]), bool)
333333

334334
for index, box in enumerate(text_proposals):
335335
successions = self.get_successions(index)
@@ -381,7 +381,7 @@ def fit_y(x, y, x1, x2):
381381
text_lines[:, :4].clip(min=0, max=(im_size[1] - 1, im_size[0] - 1, im_size[1] - 1, im_size[0] - 1),
382382
out=text_lines[:, :4])
383383

384-
text_recs = np.zeros((len(text_lines), 9), np.float)
384+
text_recs = np.zeros((len(text_lines), 9), float)
385385
for index, line in enumerate(text_lines):
386386
xmin, ymin, xmax, ymax = line[0], line[1], line[2], line[3]
387387
text_recs[index, 0], text_recs[index, 1], text_recs[index, 2], text_recs[index, 3] = xmin, ymin, xmax, ymin

tools/accuracy_checker/openvino/tools/accuracy_checker/adapters/kaldi_asr_decoder.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,12 @@ def _dump_as_binary(out_file):
187187
with out_file.open('wb') as fd:
188188
fd.write(str.encode(utterance_key + " "))
189189
fd.write(str.encode('\0B'))
190-
if mat.dtype not in [np.float32, np.float64]:
190+
try:
191+
float64 = np.float64
192+
except:
193+
float64 = float
194+
195+
if mat.dtype not in [np.float32, float64]:
191196
raise RuntimeError("Unsupported numpy dtype: {}".format(mat.dtype))
192197
mat_type = 'FM' if mat.dtype == np.float32 else 'DM'
193198
fd.write(str.encode(mat_type + " "))

0 commit comments

Comments
 (0)