Closed jonykoren closed 4 years ago
I'm trying to inference on custom dataset that is grayscale (128,128,1) by:
import skimage image_id = random.choice(val.image_ids)
image, image_meta, gt_class_id, gt_bbox, gt_mask =\ load_image_gt(val, inference_config, image_id, use_mini_mask=False) info = val.image_info[image_id] print("image ID: {}.{} ({}) {}".format(info["source"], info["id"], image_id, val.image_reference(image_id)))
results = model.detect([image], verbose=1) r = results[0]
print(image.shape) print (r['class_ids'][0]) print (r['rois'][0])
image = skimage.color.gray2rgb(image) image = np.squeeze(image, axis=2)
print(image.shape) class_names = ["BG", "nodules"] visualize.display_instances(image, r['rois'], r['masks'], r['class_ids'], class_names, r['scores'], ax=get_ax())
================================================================
utils.py:
def load_image(self, image_id): """Load the specified image and return a [H,W,3] Numpy array. """ # Load image image = skimage.io.imread(self.image_info[image_id]['path'], as_gray=True)*255 image = np.squeeze(image, axis=2) image = skimage.color.gray2rgb(image) #image = np.expand_dims(image, axis=-1).astype(np.unit8) # If grayscale. Convert to RGB for consistency. if image.ndim != 3: image = skimage.color.gray2rgb(image) return image
image ID: nodules.31 (31) ['nodules'] Processing 1 images image shape: (128, 128, 1) min: 0.14708 max: 0.14708 molded_images shape: (1, 128, 128, 1) min: -123.55292 max: -123.55292 image_metas shape: (1, 10) min: 0.00000 max: 128.00000
but displaying very bad detection(and where is the image?)
Hello i have the same problem, how did you solve it?
I'm trying to inference on custom dataset that is grayscale (128,128,1) by:
import skimage image_id = random.choice(val.image_ids)
image, image_meta, gt_class_id, gt_bbox, gt_mask =\ load_image_gt(val, inference_config, image_id, use_mini_mask=False) info = val.image_info[image_id] print("image ID: {}.{} ({}) {}".format(info["source"], info["id"], image_id, val.image_reference(image_id)))
Run object detection
results = model.detect([image], verbose=1) r = results[0]
print(image.shape) print (r['class_ids'][0]) print (r['rois'][0])
image = skimage.color.gray2rgb(image) image = np.squeeze(image, axis=2)
print(image.shape) class_names = ["BG", "nodules"] visualize.display_instances(image, r['rois'], r['masks'], r['class_ids'], class_names, r['scores'], ax=get_ax())
================================================================
utils.py:
================================================================
image ID: nodules.31 (31) ['nodules'] Processing 1 images image shape: (128, 128, 1) min: 0.14708 max: 0.14708 molded_images shape: (1, 128, 128, 1) min: -123.55292 max: -123.55292 image_metas shape: (1, 10) min: 0.00000 max: 128.00000
but displaying very bad detection(and where is the image?)