当前位置: 首页>>代码示例>>Python>>正文


Python image.resize_image方法代码示例

本文整理汇总了Python中keras_retinanet.utils.image.resize_image方法的典型用法代码示例。如果您正苦于以下问题:Python image.resize_image方法的具体用法?Python image.resize_image怎么用?Python image.resize_image使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在keras_retinanet.utils.image的用法示例。


在下文中一共展示了image.resize_image方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_rcnn_detection

# 需要导入模块: from keras_retinanet.utils import image [as 别名]
# 或者: from keras_retinanet.utils.image 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 
开发者ID:kirumang,项目名称:Pix2Pose,代码行数:21,代码来源:5_evaluation_bop_icp3d.py

示例2: get_rcnn_detection

# 需要导入模块: from keras_retinanet.utils import image [as 别名]
# 或者: from keras_retinanet.utils.image 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 
开发者ID:kirumang,项目名称:Pix2Pose,代码行数:35,代码来源:5_evaluation_bop_basic.py

示例3: get_retinanet_detection

# 需要导入模块: from keras_retinanet.utils import image [as 别名]
# 或者: from keras_retinanet.utils.image 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 
开发者ID:kirumang,项目名称:Pix2Pose,代码行数:29,代码来源:5_evaluation_bop_basic.py

示例4: detect

# 需要导入模块: from keras_retinanet.utils import image [as 别名]
# 或者: from keras_retinanet.utils.image import resize_image [as 别名]
def detect(self, img_path, min_prob=0.6):
        image = read_image_bgr(img_path)
        image = preprocess_image(image)
        image, scale = resize_image(image)
        boxes, scores, labels = Detector.detection_model.predict_on_batch(np.expand_dims(image, axis=0))
        boxes /= scale
        processed_boxes = []
        for box, score, label in zip(boxes[0], scores[0], labels[0]):
            if score < min_prob:
                continue
            box = box.astype(int).tolist()
            label = Detector.classes[label]
            processed_boxes.append({'box': box, 'score': score, 'label': label})
            
        return processed_boxes 
开发者ID:notAI-tech,项目名称:NudeNet,代码行数:17,代码来源:detector.py

示例5: process_detection

# 需要导入模块: from keras_retinanet.utils import image [as 别名]
# 或者: from keras_retinanet.utils.image import resize_image [as 别名]
def process_detection(self, color_img):

        H, W = color_img.shape[:2]

        pre_image = preprocess_image(color_img)
        res_image, scale = resize_image(pre_image)

        batch_image = np.expand_dims(res_image, axis=0)
        print batch_image.shape
        print batch_image.dtype
        boxes, scores, labels = self.detector.predict_on_batch(batch_image)


        valid_dets = np.where(scores[0] >= self.det_threshold)

        boxes /= scale

        scores = scores[0][valid_dets]
        boxes = boxes[0][valid_dets]
        labels = labels[0][valid_dets]

        filtered_boxes = []
        filtered_scores = []
        filtered_labels = []

        for box,score,label in zip(boxes, scores, labels):

            box[0] = np.minimum(np.maximum(box[0],0),W)
            box[1] = np.minimum(np.maximum(box[1],0),H)
            box[2] = np.minimum(np.maximum(box[2],0),W)
            box[3] = np.minimum(np.maximum(box[3],0),H)

            bb_xywh = np.array([box[0],box[1],box[2]-box[0],box[3]-box[1]])
            if bb_xywh[2] < 0 or bb_xywh[3] < 0:
                continue

            filtered_boxes.append(bb_xywh)
            filtered_scores.append(score)
            filtered_labels.append(label)
        return (filtered_boxes, filtered_scores, filtered_labels) 
开发者ID:DLR-RM,项目名称:AugmentedAutoencoder,代码行数:42,代码来源:aae_retina_pose_estimator.py

示例6: predict

# 需要导入模块: from keras_retinanet.utils import image [as 别名]
# 或者: from keras_retinanet.utils.image import resize_image [as 别名]
def predict(imagePath):
	# load the input image (in BGR order), clone it, and preprocess it
	image = read_image_bgr(imagePath)
	output = image.copy()
	image = preprocess_image(image)
	(image, scale) = resize_image(image)
	image = np.expand_dims(image, axis=0)

	# detect objects in the input image and correct for the image scale
	(boxes, scores, labels) = model.predict_on_batch(image)
	boxes /= scale

	# loop over the detections
	for (box, score, label) in zip(boxes[0], scores[0], labels[0]):
		# filter out weak detections
		if score < 0.5:
			continue
	
		# convert the bounding box coordinates from floats to integers
		box = box.astype("int")
	
		# build the label and draw the label + bounding box on the output
		# image
		label = "{}: {:.2f}".format(LABELS[label], score)
		cv2.rectangle(output, (box[0], box[1]), (box[2], box[3]),
			(0, 255, 0), 2)
		cv2.putText(output, label, (box[0], box[1] - 10),
			cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)

	# show the output image
	cv2.imwrite("prediction.jpg", output)
	return boxes 
开发者ID:holms-ur,项目名称:fine-tuning,代码行数:34,代码来源:predict.py


注:本文中的keras_retinanet.utils.image.resize_image方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。