Skip to content

Commit f180d8e

Browse files
committed
update numpy type conversion argument string to np value
1 parent 829b9b0 commit f180d8e

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

generator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ def load(self):
6969
if dir_name != 'unknown':
7070
y[self.class_names.index(dir_name)] = 1.0
7171
batch_y.append(y)
72-
batch_x = np.asarray(batch_x).reshape((self.batch_size,) + self.input_shape).astype('float32')
73-
batch_y = np.asarray(batch_y).reshape((self.batch_size, self.num_classes)).astype('float32')
72+
batch_x = np.asarray(batch_x).reshape((self.batch_size,) + self.input_shape).astype(np.float32)
73+
batch_y = np.asarray(batch_y).reshape((self.batch_size, self.num_classes)).astype(np.float32)
7474
return batch_x, batch_y
7575

7676
def preprocess(self, img, aug=False):
@@ -79,7 +79,7 @@ def preprocess(self, img, aug=False):
7979
img = self.transform(image=img)['image']
8080
if self.input_shape[-1] == 3:
8181
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) # swap rb
82-
x = np.asarray(img).reshape(self.input_shape).astype('float32') / 255.0
82+
x = np.asarray(img).reshape(self.input_shape).astype(np.float32) / 255.0
8383
return x
8484

8585
def get_next_image_path(self):

sigmoid_classifier.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def draw_cam(self, x, label, window_size_h=512, alpha=0.6):
219219
cam -= np.min(cam)
220220
cam /= np.max(cam)
221221
cam *= 255.0
222-
cam = cam.astype('uint8')
222+
cam = cam.astype(np.uint8)
223223
cam = cv2.resize(cam, (img_w, img_h))
224224
cam = cam[..., np.newaxis]
225225
cam = np.concatenate([cam, cam, cam], axis=-1)
@@ -228,8 +228,8 @@ def draw_cam(self, x, label, window_size_h=512, alpha=0.6):
228228
cam_blended = cv2.addWeighted((org_image * 255).astype(np.uint8), alpha, cam_jet, (1 - alpha), 0)
229229

230230
label_box = np.zeros((img_h, 20, 3), dtype=np.float32) + float(label == idx)
231-
label_box = (label_box * 255.0).astype('uint8')
232-
org_image = (org_image * 255.0).astype('uint8')
231+
label_box = (label_box * 255.0).astype(np.uint8)
232+
org_image = (org_image * 255.0).astype(np.uint8)
233233
grid_row = np.concatenate([label_box, org_image, cam, cam_jet, cam_blended], axis=1)
234234
image_grid = np.append(image_grid, grid_row, axis=0) if image_grid is not None else grid_row.copy()
235235
if window_size_h is not None:

0 commit comments

Comments
 (0)