本文整理汇总了Python中mrcnn.utils.resize_image方法的典型用法代码示例。如果您正苦于以下问题:Python utils.resize_image方法的具体用法?Python utils.resize_image怎么用?Python utils.resize_image使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mrcnn.utils
的用法示例。
在下文中一共展示了utils.resize_image方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_rcnn_detection
# 需要导入模块: from mrcnn import utils [as 别名]
# 或者: from mrcnn.utils import resize_image [as 别名]
def get_rcnn_detection(self,image_t):
image_t_resized, window, scale, padding, crop = utils.resize_image(
np.copy(image_t),
min_dim=self.config.IMAGE_MIN_DIM,
min_scale=self.config.IMAGE_MIN_SCALE,
max_dim=self.config.IMAGE_MAX_DIM,
mode=self.config.IMAGE_RESIZE_MODE)
if(scale!=1):
print("Warning.. have to adjust the scale")
results = self.detection_model.detect([image_t_resized], verbose=0)
r = results[0]
rois = r['rois']
rois = rois - [window[0],window[1],window[0],window[1]]
obj_orders = np.array(r['class_ids'])-1
obj_ids=[]
for obj_order in obj_orders:
obj_ids.append(self.detection_labels[obj_order])
#now c_ids are the same annotation those of the names of ply/gt files
scores = np.array(r['scores'])
masks = r['masks'][window[0]:window[2],window[1]:window[3],:]
return rois,obj_orders,obj_ids,scores,masks
示例2: get_rcnn_detection
# 需要导入模块: from mrcnn import utils [as 别名]
# 或者: from mrcnn.utils import resize_image [as 别名]
def get_rcnn_detection(image_t,model):
image_t_resized, window, scale, padding, crop = utils.resize_image(
np.copy(image_t),
min_dim=config.IMAGE_MIN_DIM,
min_scale=config.IMAGE_MIN_SCALE,
max_dim=config.IMAGE_MAX_DIM,
mode=config.IMAGE_RESIZE_MODE)
if(scale!=1):
print("Warning.. have to adjust the scale")
results = model.detect([image_t_resized], verbose=0)
r = results[0]
rois = r['rois']
rois = rois - [window[0],window[1],window[0],window[1]]
obj_orders = np.array(r['class_ids'])-1
obj_ids = model_ids[obj_orders]
#now c_ids are the same annotation those of the names of ply/gt files
scores = np.array(r['scores'])
masks = r['masks'][window[0]:window[2],window[1]:window[3],:]
return rois,obj_orders,obj_ids,scores,masks
示例3: mold_inputs
# 需要导入模块: from mrcnn import utils [as 别名]
# 或者: from mrcnn.utils import resize_image [as 别名]
def mold_inputs(self, images):
"""Takes a list of images and modifies them to the format expected
as an input to the neural network.
images: List of image matrices [height,width,depth]. Images can have
different sizes.
Returns 3 Numpy matrices:
molded_images: [N, h, w, 3]. Images resized and normalized.
image_metas: [N, length of meta data]. Details about each image.
windows: [N, (y1, x1, y2, x2)]. The portion of the image that has the
original image (padding excluded).
"""
molded_images = []
image_metas = []
windows = []
for image in images:
# Resize image
# TODO: move resizing to mold_image()
molded_image, window, scale, padding, crop = utils.resize_image(
image,
min_dim=self.config.IMAGE_MIN_DIM,
min_scale=self.config.IMAGE_MIN_SCALE,
max_dim=self.config.IMAGE_MAX_DIM,
mode=self.config.IMAGE_RESIZE_MODE)
molded_image = mold_image(molded_image, self.config)
# Build image_meta
image_meta = compose_image_meta(
0, image.shape, molded_image.shape, window, scale,
np.zeros([self.config.NUM_CLASSES], dtype=np.int32))
# Append
molded_images.append(molded_image)
windows.append(window)
image_metas.append(image_meta)
# Pack into arrays
molded_images = np.stack(molded_images)
image_metas = np.stack(image_metas)
windows = np.stack(windows)
return molded_images, image_metas, windows
示例4: get_rcnn_detection
# 需要导入模块: from mrcnn import utils [as 别名]
# 或者: from mrcnn.utils import resize_image [as 别名]
def get_rcnn_detection(image_t,model):
image_t_resized, window, scale, padding, crop = utils.resize_image(
np.copy(image_t),
min_dim=config.IMAGE_MIN_DIM,
min_scale=config.IMAGE_MIN_SCALE,
max_dim=config.IMAGE_MAX_DIM,
mode=config.IMAGE_RESIZE_MODE)
if(scale!=1):
print("Warning.. have to adjust the scale")
results = model.detect([image_t_resized], verbose=0)
r = results[0]
rois = r['rois']
if(scale!=1):
masks_all = r['masks'][window[0]:window[2],window[1]:window[3],:]
masks = np.zeros((image_t.shape[0],image_t.shape[1],masks_all.shape[2]),bool)
for mask_id in range(masks_all.shape[2]):
masks[:,:,mask_id]=resize(masks_all[:,:,mask_id].astype(np.float),(image_t.shape[0],image_t.shape[1]))>0.5
#resize all the masks
rois=rois/scale
window = np.array(window)
window[0] = window[0]/scale
window[1] = window[1]/scale
window[2] = window[2]/scale
window[3] = window[3]/scale
else:
masks = r['masks'][window[0]:window[2],window[1]:window[3],:]
rois = rois - [window[0],window[1],window[0],window[1]]
obj_orders = np.array(r['class_ids'])-1
obj_ids = model_ids[obj_orders]
#now c_ids are the same annotation those of the names of ply/gt files
scores = np.array(r['scores'])
return rois,obj_orders,obj_ids,scores,masks
示例5: get_retinanet_detection
# 需要导入模块: from mrcnn import utils [as 别名]
# 或者: from mrcnn.utils import resize_image [as 别名]
def get_retinanet_detection(image_t,model):
image = preprocess_image(image_t[:,:,::-1]) #needs bgr order bgr?
image, scale = resize_image(image)
boxes, scores, labels = model.predict_on_batch(np.expand_dims(image, axis=0))
boxes /= scale
boxes = boxes[0]
scores = scores[0]
labels = labels[0]
score_mask = scores>0
if(np.sum(score_mask)==0):
return np.array([[-1,-1,-1,-1]]),-1,-1,-1
else:
scores = scores[score_mask]
boxes = boxes[score_mask]
labels = labels[score_mask]
rois = np.zeros((boxes.shape[0],4),np.int)
rois[:,0] = boxes[:,1]
rois[:,1] = boxes[:,0]
rois[:,2] = boxes[:,3]
rois[:,3] = boxes[:,2]
obj_orders = labels
obj_ids = model_ids[obj_orders]
return rois,obj_orders,obj_ids,scores
示例6: mold_inputs
# 需要导入模块: from mrcnn import utils [as 别名]
# 或者: from mrcnn.utils import resize_image [as 别名]
def mold_inputs(self, images):
"""Takes a list of images and modifies them to the format expected
as an input to the neural network.
images: List of image matrices [height,width,depth]. Images can have
different sizes.
Returns 3 Numpy matrices:
molded_images: [N, h, w, 3]. Images resized and normalized.
image_metas: [N, length of meta data]. Details about each image.
windows: [N, (y1, x1, y2, x2)]. The portion of the image that has the
original image (padding excluded).
"""
molded_images = []
image_metas = []
windows = []
for image in images:
# Resize image
# TODO: move resizing to mold_image()
molded_image, window, scale, padding, crop = utils.resize_image(
image,
min_dim=self.config.IMAGE_MIN_DIM,
min_scale=self.config.IMAGE_MIN_SCALE,
max_dim=self.config.IMAGE_MAX_DIM,
mode=self.config.IMAGE_RESIZE_MODE)
molded_image = mold_image(molded_image, self.config)
# Build image_meta
image_meta = compose_image_meta(
0, image.shape, molded_image.shape, window, scale,
np.zeros([self.config.NUM_CLASSES], dtype=np.int32))
# Append
molded_images.append(molded_image)
windows.append(window)
image_metas.append(image_meta)
# Pack into arrays
molded_images = np.stack(molded_images)
image_metas = np.stack(image_metas)
windows = np.stack(windows)
return molded_images, image_metas, windows
示例7: mold_inputs
# 需要导入模块: from mrcnn import utils [as 别名]
# 或者: from mrcnn.utils import resize_image [as 别名]
def mold_inputs(self, images):
"""Takes a list of images and modifies them to the format expected
as an input to the neural network.
images: List of image matricies [height,width,depth]. Images can have
different sizes.
Returns 3 Numpy matricies:
molded_images: [N, h, w, 3]. Images resized and normalized.
image_metas: [N, length of meta data]. Details about each image.
windows: [N, (y1, x1, y2, x2)]. The portion of the image that has the
original image (padding excluded).
"""
molded_images = []
image_metas = []
windows = []
for image in images:
# Resize image
# TODO: move resizing to mold_image()
molded_image, window, scale, padding, crop = utils.resize_image(
image,
min_dim=self.config.IMAGE_MIN_DIM,
min_scale=self.config.IMAGE_MIN_SCALE,
max_dim=self.config.IMAGE_MAX_DIM,
mode=self.config.IMAGE_RESIZE_MODE)
molded_image = mold_image(molded_image, self.config)
# Build image_meta
image_meta = compose_image_meta(
0, image.shape, molded_image.shape, window, scale,
np.zeros([self.config.NUM_CLASSES], dtype=np.int32))
# Append
molded_images.append(molded_image)
windows.append(window)
image_metas.append(image_meta)
# Pack into arrays
molded_images = np.stack(molded_images)
image_metas = np.stack(image_metas)
windows = np.stack(windows)
return molded_images, image_metas, windows