client_seving显示图像太大(3,225,225)
Created by: stidk
W0916 11:52:00.469072 6493 redis_protocol.cpp:69] No corresponding PipelinedInfo in socket E0916 11:52:00.469117 6493 input_messenger.cpp:113] A message from 127.0.0.1:9292(protocol=esp) is bigger than 536870912 bytes, the connection will be closed. Set max_body_size to allow bigger messages W0916 11:52:00.469156 6493 input_messenger.cpp:276] Close fd=4 SocketId=1@127.0.0.1:9292@51838: too big data W0916 11:52:00.469290 6460 predictor.hpp:129] inference call failed, message: [E22]1/1 channels failed, fail_limit=1 [C0][E22]Close fd=4 SocketId=1@127.0.0.1:9292@51838: too big data 但是我看别人的也是这么搞得,别人还是(3,640,640)的图片都没报图片太大。为什么我就报错了呢
! LD_LIBRARY_PATH=/home/aistudio/env/cuda-9.0/lib64:$LD_LIBRARY_PATH &&
python -m paddle_serving_server_gpu.serve --model uci_car_model --port 9292 --name uci --gpu_id 0(运行serving服务)
from paddle_serving_client import Client import cv2 import numpy as np
client = Client() client.load_client_config("uci_car_client/serving_client_conf.prototxt") client.connect(["127.0.0.1:9292"]) def transform_img(img): # 将图片尺寸缩放道 224x224 img = cv2.resize(img, (224, 224)) # 读入的图像数据格式是[H, W, C] # 使用转置操作将其变成[C, H, W] img = np.transpose(img, (2,0,1)) img = img.astype('float32') # 将数据范围调整到[-1.0, 1.0]之间 img = img / 255. img = img * 2.0 - 1.0 return img def read_img(file_name): # filepath = os.path.join(datadir, name) img = cv2.imread(file_name) # print(img) img = transform_img(img) return img data = read_img('6/16c547f-1c20fa9a74ee4ba2acb152fbddd0a2d5-front.jpg') print(data.shape,data.dtype,data) fetch_map = client.predict(feed={"x": data}, fetch=["type"]) print(fetch_map) (client运行文件)
feed_var { name: "img" alias_name: "x" is_lod_tensor: false feed_type: 1 shape: 3 shape: 224 shape: 224 } fetch_var { name: "fc_2.tmp_2" alias_name: "type" is_lod_tensor: false fetch_type: 1 shape: 2 } (serving_client_conf.prototxt文件)
! LD_LIBRARY_PATH=/home/aistudio/env/cuda-9.0/lib64:$LD_LIBRARY_PATH &&
python -m paddle_serving_server_gpu.serve --model uci_car_model --port 9292 --name uci --gpu_id 0 --max_body_size 100000000000000000
(设置max_body_size的值,报错依然不变)