예제 #1
0
 def pdx_predict_det_seg(self,img):
     '''
     实例分割接口
     将帧图发送服务端,返回结果
     可视化结果
     '''
     or_img = img
     img = image_to_base64(img)
     respone = self.stub.paddlex_predict_det_seg(PaddleXserver_pb2.image(
         _image = img
     ))
     result = []
     for value in respone.boxes_seg:
         dict_temp = {}
         dict_temp['category_id'] = value.category_id
         dict_temp['bbox'] = []
         dict_temp['bbox'].append(value.bbox.xmin)
         dict_temp['bbox'].append(value.bbox.ymin)
         dict_temp['bbox'].append(value.bbox.width)
         dict_temp['bbox'].append(value.bbox.height)
         dict_temp['score'] = value.score
         dict_temp['mask'] = base64_to_image(value._mask)
         dict_temp['category'] = value.category
         result.append(dict_temp)
     visualize_img = pdx.det.visualize(or_img,result,threshold=0,save_dir=None)
     return visualize_img
예제 #2
0
 def pdx_predict_det(self,img):
     '''
     目标检测接口
     将帧图片传给服务端预测返回筛选之后的boxes
     将poxes的结果可视化
     '''
     or_img = img
     img = image_to_base64(img)
     respone = self.stub.paddlex_predict_det(PaddleXserver_pb2.image(
         _image = img
     ))
     result = []
     for value in respone.boxes:
         dict_temp = {}
         dict_temp['category_id'] = value.category_id
         dict_temp['bbox'] = []
         dict_temp['bbox'].append(value.bbox.xmin)
         dict_temp['bbox'].append(value.bbox.ymin)
         dict_temp['bbox'].append(value.bbox.width)
         dict_temp['bbox'].append(value.bbox.height)
         dict_temp['score'] = value.score
         dict_temp['category'] = value.category
         result.append(dict_temp)
     visualize_img = pdx.det.visualize(or_img,result,threshold=0,save_dir=None)
     return visualize_img
예제 #3
0
 def pdx_predict_cls(self,img):
     '''
     图像分类接口
     将帧图发送服务端,返回结果一个
     '''
     
     img = image_to_base64(img)
     respone = self.stub.paddlex_predict_cls(PaddleXserver_pb2.image(
         _image = img
     ))
     result = []
     dict_temp = {}
     dict_temp['category_id'] = respone.category_id
     dict_temp['score'] = respone.score
     dict_temp['category'] = respone.category
     result.append(dict_temp)        
     return result
예제 #4
0
 def pdx_predict_seg(self,img):
     '''
     语义分割接口
     将帧图发送服务端,返回一个分割结果
     '''
     or_img = img
     img = image_to_base64(img)
     respone = self.stub.paddlex_predict_seg(PaddleXserver_pb2.image(
         _image = img
     ))
     dict_temp = {}
     dict_temp['score_map'] = []
     for value in respone._score_map:
         temp = base64_to_image(value.value)
         temp = temp[:,:,np.newaxis]/255
         dict_temp['score_map'].append(temp.astype('float32'))
     dict_temp['score_map'] = np.concatenate(dict_temp['score_map'],axis=2)
     dict_temp['label_map'] = base64_to_image(respone.label_map)
     visualize_img = pdx.seg.visualize(or_img, dict_temp, weight=respone.set_threshold, save_dir=None, color=None)
     return visualize_img