mdietrichstein / tensorflow-open_nsfw

Tensorflow Implementation of Yahoo's Open NSFW Model
Other
430 stars 136 forks source link

Prediction via Cloud ML not working #13

Closed emilwidlund closed 6 years ago

emilwidlund commented 6 years ago

I'm trying to run predictions on the model via Google Cloud ML. I'm however getting this error when I execute my request:

{"error":"Prediction failed: Error during model execution: AbortionError(code=StatusCode.INVALID_ARGUMENT, details=\"NodeDef mentions attr 'identical_element_shapes' not in Op<name=TensorArrayV3; signature=size:int32 -> handle:resource, flow:float; attr=dtype:type; attr=element_shape:shape,default=<unknown>; attr=dynamic_size:bool,default=false; attr=clear_after_read:bool,default=true; attr=tensor_array_name:string,default=\"\"; is_stateful=true>; NodeDef: map/TensorArray = TensorArrayV3[_output_shapes=[[2], []], clear_after_read=true, dtype=DT_STRING, dynamic_size=false, element_shape=<unknown>, identical_element_shapes=true, tensor_array_name=\"\", _device=\"/job:localhost/replica:0/task:0/cpu:0\"](map/strided_slice)\n\t [[Node: map/TensorArray = TensorArrayV3[_output_shapes=[[2], []], clear_after_read=true, dtype=DT_STRING, dynamic_size=false, element_shape=<unknown>, identical_element_shapes=true, tensor_array_name=\"\", _device=\"/job:localhost/replica:0/task:0/cpu:0\"](map/strided_slice)]]\")"}

I've exported the saved model via the tool and it deployed successfully in the Google Cloud Console.

Here is the relevant part of my code:

        # ...
       temp_base64 = base64.b64encode(temp.getvalue())

        model_name = 'projects/{}/models/{}'.format('glotter-80ac0', 'NSFW')

        ml = discovery.build('ml', 'v1')

        requestDict = {
            "instances": [{
                "b64": temp_base64.decode('utf-8')
            }]
        }

        mlRequest = ml.projects().predict(name=model_name, body=requestDict)

        try:
            response = mlRequest.execute()
            return jsonify(response)
        except errors.HttpError:
            print('There was an error creating the model. Check the details:')
            print(errors.HttpError._get_reason())
mdietrichstein commented 6 years ago

I've exported the saved model via the tool and it deployed successfully in the Google Cloud Console.

That means you've used tools/export_savedmodel.py, correct?

The error message indicates that cloud ml has problems loading the model due to some unknown ops/attributes. Does your ML engine environment use the same tensorflow version that you've used to export the model?