serving icon indicating copy to clipboard operation
serving copied to clipboard

requests.exceptions.HTTPError: 400 Client Error: Bad Request for url

Open Anatolist opened this issue 6 years ago • 4 comments

Hello everyone,

I have served my custom model an object detection API for cellphones basic on a pre-trained model. So, I want to send requests to the service: http://localhost:8501/v1/models/cellphone:predict
The HTTP\REST API running correctly.

I used Docker and TensorFlow-serving.

For the requests, I used a python script that returns the avg time, here is the python script: https://raw.githubusercontent.com/tensorflow/serving/master/tensorflow_serving/example/resnet_client.py

The only changes were the image and my server model:

# The server URL specifies the endpoint of your server running the ResNet
# model with the name "resnet" and using the predict interface.
SERVER_URL = 'http://localhost:8501/v1/models/cellphone:predict'

# The image URL is the location of the image we should send to the server
IMAGE_URL = 'https://assets.kotsovolos.gr/product/199086-b.jpg'

and when I run the $ python resnet_client.py I take this error:

Traceback (most recent call last): File "resnet_client.py", line 73, in <module> main() File "resnet_client.py", line 57, in main response.raise_for_status() File "/usr/local/lib/python3.5/dist-packages/requests/models.py", line 941, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http://localhost:8501/v1/models/cellphone:predict

Is there anybody that can help me to send the correct requests? Thank U in advanced

System information

  • Linux Ubuntu 16.04 -python 3.5
  • TensorFlow Serving installed from binary
  • TensorFlow ModelServer: 2.1.0-rc1 TensorFlow Library: 2.1.0

Anatolist avatar May 25 '20 19:05 Anatolist

Can you share the signature def of the model? Also please provide all the steps for us to reproduce this issue. You can also look at the following issue and let me know if it helps. Thanks!

gowthamkpr avatar May 26 '20 18:05 gowthamkpr

@gowthamkpr thank you for your response. My model is produced from a pre-trained model for object detection. Is that you want to?

`MetaGraphDef with tag-set: 'serve' contains the following SignatureDefs:

signature_def['serving_default']: The given SavedModel SignatureDef contains the following input(s): inputs['inputs'] tensor_info: dtype: DT_UINT8 shape: (-1, -1, -1, 3) name: image_tensor:0 The given SavedModel SignatureDef contains the following output(s): outputs['detection_boxes'] tensor_info: dtype: DT_FLOAT shape: (-1, 100, 4) name: detection_boxes:0 outputs['detection_classes'] tensor_info: dtype: DT_FLOAT shape: (-1, 100) name: detection_classes:0 outputs['detection_multiclass_scores'] tensor_info: dtype: DT_FLOAT shape: (-1, 100, 2) name: detection_multiclass_scores:0 outputs['detection_scores'] tensor_info: dtype: DT_FLOAT shape: (-1, 100) name: detection_scores:0 outputs['num_detections'] tensor_info: dtype: DT_FLOAT shape: (-1) name: num_detections:0 outputs['raw_detection_boxes'] tensor_info: dtype: DT_FLOAT shape: (-1, -1, 4) name: raw_detection_boxes:0 outputs['raw_detection_scores'] tensor_info: dtype: DT_FLOAT shape: (-1, -1, 2) name: raw_detection_scores:0 Method name is: tensorflow/serving/predict`

Anatolist avatar May 26 '20 20:05 Anatolist

hi, Ι found this solution here https://stackoverflow.com/questions/58172536/tensorflow-serving-type-object-is-not-of-expected-type-uint8 Thank you

Anatolist avatar May 27 '20 20:05 Anatolist

@Anatolist I had similar issue as yours! Thank you so much i've been trying to solve this problem for 2 days. Although, the output seemed like a cluster of float number in an array even though i provided only one picture. Does the result seems similar like yours maybe? I followed the client file the one you referenced:

{
    "predictions": [
        {
            "detection_boxes": [[0.107028872, 0.209838, 0.969092488, 0.86740756], [0.332620442, 0.116767675, 0.893690884, 0.831270337], [0.263605773, 0.224990875, 0.332245052, 0.270270497], [0.123739161, 0.164657533, 0.30629608, 0.4292202], [0.0978057534, 0.175626457, 0.259873211, 0.415450394], [0.0, 0.131391406, 0.445053458, 0.933340192], [0.259044319, 0.0890135691, 0.417004138, 0.328531921], [0.118335746, 0.203636914, 0.340175629, 0.379058093], [0.175858155, 0.140573025, 0.421215594, 0.29723981], [0.325795859, 0.171284482, 0.371893197, 0.209172294], [0.263217866, 0.73665905, 0.420972228, 0.968136549], [0.183671638, 0.218362555, 0.261035442, 0.267013103], [0.313139379, 0.740012407, 0.479442835, 0.96667254], [0.197118208, 0.294473648, 0.263320416, 0.328394413], [0.362548858, 0.069219768, 0.532456815, 0.313539296], [0.815391064, 0.182027817, 1.0, 0.687877893], [0.117595717, 0.139169291, 0.374440789, 0.317288458], [0.219844386, 0.121053696, 0.376044035, 0.374979436], [0.126154825, 0.638691068, 0.383982, 0.790356159], [0.384735674, 0.141857818, 0.646451, 0.295174241], [0.210919872, 0.676267505, 0.368015885, 0.888611078], [0.21371673, 0.0929844752, 0.473931074, 0.239790022], [0.00531731546, 0.0260830522, 0.28511256, 0.963852584], [0.264191896, 0.169066697, 0.31717363, 0.201905549], [0.331473172, 0.241827145, 0.370350599, 0.26249212], [0.252038121, 0.676721454, 0.425645053, 0.898021698], [0.199005023, 0.704228163, 0.484137654, 0.850419044], [0.102564886, 0.588336229, 0.320324242, 0.729575157], [0.164548665, 0.73389256, 0.467152089, 0.871981], [0.871969223, 0.106431991, 0.99632597, 0.774043798], [0.736877203, 0.210481226, 0.866689801, 0.500995], [0.630812407, 0.105723456, 0.792535424, 0.368689418], [0.34065032, 0.0852565914, 0.606121898, 0.233272508], [0.696348369, 0.18692106, 0.743289649, 0.216839671], [0.797646105, 0.349267, 0.847449124, 0.380024612], [0.78894794, 0.846283138, 0.851313949, 0.923086], [0.29667002, 0.142796874, 0.54602313, 0.303987354], [0.624124229, 0.0539536774, 0.794105947, 0.292655438], [0.14508985, 0.560809493, 0.319512367, 0.857706189], [0.109636679, 0.556116521, 0.253265321, 0.822011173], [0.323285848, 0.0796785802, 0.483391136, 0.314626694], [0.379116416, 0.73442471, 0.518948317, 0.957572222], [0.369522631, 0.226858705, 0.420262098, 0.25414747], [0.370857894, 0.283281207, 0.44624728, 0.319785357], [0.155858397, 0.62883544, 0.217395604, 0.701523662], [0.182309106, 0.650932252, 0.439041555, 0.795435727], [0.193241447, 0.794422448, 0.519402, 0.897210777], [0.169092312, 0.714257717, 0.219513074, 0.742997646], [0.738690674, 0.85553658, 0.789565, 0.925616741], [0.265439898, 0.303525478, 0.31205973, 0.323120326], [0.167930484, 0.100835823, 0.415085137, 0.249405682], [0.700097, 0.236545905, 0.743257463, 0.264222801], [0.714457273, 0.219665289, 0.806844473, 0.280053884], [0.417155057, 0.0574786961, 0.57804513, 0.309776396], [0.413117588, 0.219532251, 0.489553571, 0.27291432], [0.232549101, 0.724793553, 0.262107342, 0.74399209], [0.374145806, 0.628972769, 0.993485272, 1.0], [0.685286045, 0.765583515, 0.974332929, 0.992163777], [0.133244231, 0.702391684, 0.412843049, 0.855020463], [0.473554641, 0.0970380455, 0.632310748, 0.365262032], [0.339233428, 0.217836618, 0.582724333, 0.359372437], [0.148960039, 0.25070861, 0.223732755, 0.314208299], [0.401296794, 0.177822918, 0.481223583, 0.212214172], [0.150878817, 0.488217324, 0.318704933, 0.771887183], [0.340498, 0.296094239, 0.370591313, 0.313421071], [0.323045105, 0.841504276, 0.394941, 0.871252954], [0.375551403, 0.193289489, 0.421867669, 0.21235618], [0.318087, 0.4835186, 0.474584609, 0.742385], [0.460468173, 0.231501564, 0.548261404, 0.279662579], [0.48146373, 0.208882138, 0.645914614, 0.464239299], [0.405755639, 0.163454026, 0.846319318, 0.686983466], [0.334894061, 0.138832, 0.364115298, 0.155392826], [0.364814043, 0.434293, 0.529925823, 0.668124676], [0.713518322, 0.186439201, 0.781066358, 0.226424113], [0.377937675, 0.799722433, 0.527265251, 1.0], [0.275838912, 0.766225278, 0.331963956, 0.799826324], [0.211703196, 0.597383499, 0.36902976, 0.851273656], [0.394260943, 0.254843354, 0.490443885, 0.319810867], [0.226935655, 0.0572146177, 0.523194432, 0.203351289], [0.561397612, 0.152665347, 0.837993801, 0.307377487], [0.363000065, 0.227629721, 0.534234464, 0.46377641], [0.339818, 0.516548097, 0.80688, 0.812630832], [0.250349313, 0.666585684, 0.316589087, 0.694620132], [0.845309913, 0.760152698, 0.890003264, 0.799518347], [0.309367627, 0.829101622, 0.386496693, 0.85463196], [0.547074318, 0.0888551176, 0.827772, 0.262152851], [0.432090521, 0.750989914, 0.572158456, 0.969026446], [0.251818836, 0.709332228, 0.321798742, 0.741789103], [0.35995391, 0.163634822, 0.534290969, 0.405285776], [0.170568347, 0.581766605, 0.417727, 0.716001391], [0.211531743, 0.610225618, 0.264702559, 0.636707723], [0.515626788, 0.243159071, 0.574002862, 0.268073171], [0.433321953, 0.208190426, 0.724136591, 0.350871623], [0.354870647, 0.608412504, 0.412745267, 0.631603956], [0.0, 0.0, 0.163784251, 0.405261], [0.156021416, 0.641909063, 0.821173549, 1.0], [0.682302833, 0.295582443, 0.749034166, 0.324681789], [0.151138246, 0.669712842, 0.321184039, 0.903965652], [0.368382692, 0.488010466, 0.528663576, 0.748211443], [0.317210376, 0.359457254, 0.370414853, 0.378325]],
            "detection_scores": [0.963327289, 0.0107360641, 0.0104438392, 0.0100602489, 0.00984634645, 0.00980703812, 0.00972275808, 0.00907788, 0.00892261, 0.00872171391, 0.00845040381, 0.00840112, 0.00839662, 0.0083937943, 0.00824808795, 0.00824008696, 0.00821683183, 0.00821292493, 0.00812378619, 0.00804465916, 0.00800063275, 0.00800040178, 0.00784582, 0.00782101136, 0.00778457196, 0.00776600931, 0.00740229199, 0.00737342937, 0.00719804922, 0.00712469313, 0.00702558039, 0.00702239107, 0.00698272558, 0.00693768542, 0.00690988265, 0.00689990912, 0.00689423317, 0.00686183805, 0.00682931812, 0.00680525554, 0.00679429667, 0.00678283209, 0.00671706907, 0.00670305686, 0.00669310428, 0.00668921927, 0.00665129, 0.00655392092, 0.00651656976, 0.00644685933, 0.00635258155, 0.0063074776, 0.00627995841, 0.00624397816, 0.00621895213, 0.00621359423, 0.00611673156, 0.00599056575, 0.00598010886, 0.00597581919, 0.00592804234, 0.00588901341, 0.0058242986, 0.00572120957, 0.00568966335, 0.00568520091, 0.00567126321, 0.00554763339, 0.00554555282, 0.00549162552, 0.00548669789, 0.00546972081, 0.00546531, 0.00545520056, 0.00541081699, 0.00538488152, 0.00538034784, 0.00537552219, 0.00537525723, 0.0053673829, 0.00535707, 0.00533062965, 0.00531466957, 0.0053101345, 0.00525082, 0.00523842406, 0.00522809243, 0.00521674938, 0.00521600479, 0.00520708784, 0.00520363776, 0.00514298445, 0.00513519, 0.00513090426, 0.00510697952, 0.00509568024, 0.00509493845, 0.0050886767, 0.00508564571, 0.00505552301],
            "detection_classes": [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
            "num_detections": 100.0
        }
    ]
}

louiselmps avatar Jun 02 '20 06:06 louiselmps