示例#1
0
    def post(self):
        '''Make a prediction given input data'''
        result = {'status': 'error'}

        args = image_parser.parse_args()
        image_data = args['image'].read()
        image = read_image(image_data)
        label_preds = self.model_wrapper.predict(image)

        result['predictions'] = label_preds
        result['status'] = 'ok'

        return result
示例#2
0
    def post(self):
        '''Make a prediction given input data'''
        result = {'status': 'error'}

        args = image_parser.parse_args()
        image_data = args['image'].read()
        image = read_image(image_data)
        preds = self.model_wrapper.predict(image)
        
        label_preds = [{'label_id': p[0], 'label': p[1], 'probability': p[2]} for p in [x for x in preds]]
        result['predictions'] = label_preds
        result['status'] = 'ok'

        return result
示例#3
0
    def post(self):
        """Make a prediction given input data"""
        result = {'status': 'error'}

        args = image_parser.parse_args()
        image_data = args['image'].read()
        image = read_image(image_data)

        resized_im, seg_map = self.model_wrapper.predict(image)

        result['image_size'] = resized_im.size

        result['seg_map'] = seg_map
        result['status'] = 'ok'

        return result
    def post(self):
        """Make a prediction given input data"""
        result = {'status': 'error'}

        args = image_parser.parse_args()
        image_data = args['image'].read()
        try:
            image = read_image(image_data)
            preds = self.model_wrapper.predict(image)
            label_preds = [{'probability': float(preds)}]
            result['predictions'] = label_preds
            result['status'] = 'ok'
        except ValueError as e:
            abort(400, str(e))

        return result
示例#5
0
    def post(self):
        """Make a prediction given input data"""
        result = {'status': 'error'}

        args = input_parser.parse_args()
        try:
            input_data = args['file'].read()
            image = read_image(input_data)
        except OSError as e:
            abort(400,
                  "Please submit a valid image in PNG, Tiff or JPEG format")

        label_preds = self.model_wrapper.predict(image)

        result['predictions'] = label_preds
        result['status'] = 'ok'

        return result