Beispiel #1
0
 def _make_cloud_mlengine_request(examples):
   """Builds and sends requests to Cloud ML Engine."""
   api = discovery.build("ml", "v1", credentials=credentials)
   parent = "projects/%s/models/%s/versions/%s" % (cloud.default_project(),
                                                   model_name, version)
   input_data = {
       "instances": [{
           "input": {
               "b64": base64.b64encode(ex.SerializeToString())
           }
       } for ex in examples]
   }
   prediction = api.projects().predict(body=input_data, name=parent).execute()
   return prediction["predictions"]
Beispiel #2
0
 def _make_cloud_mlengine_request(examples):
   """Builds and sends requests to Cloud ML Engine."""
   api = discovery.build("ml", "v1", credentials=credentials)
   parent = "projects/%s/models/%s/versions/%s" % (cloud.default_project(),
                                                   model_name, version)
   input_data = {
       "instances": [{
           "input": {
               "b64": base64.b64encode(ex.SerializeToString())
           }
       } for ex in examples]
   }
   prediction = api.projects().predict(body=input_data, name=parent).execute()
   return prediction["predictions"]
Beispiel #3
0
 def _make_cloud_mlengine_request(examples):
   """Builds and sends requests to Cloud ML Engine."""
   api = discovery.build("ml", "v1", credentials=credentials)
   parent = "projects/%s/models/%s/versions/%s" % (cloud.default_project(),
                                                   model_name, version)
   input_data = {
       "instances": [{  # pylint: disable=g-complex-comprehension
           "input": {
               "b64": base64.b64encode(ex.SerializeToString())
           }
       } for ex in examples]
   }
   response = api.projects().predict(body=input_data, name=parent).execute()
   predictions = response["predictions"]
   for prediction in predictions:
     prediction["outputs"] = np.array([prediction["outputs"]])
     prediction["scores"] = np.array(prediction["scores"])
   return predictions