affinelayer / pix2pix-tensorflow

Tensorflow port of Image-to-Image Translation with Conditional Adversarial Nets https://phillipi.github.io/pix2pix/
MIT License
5.07k stars 1.3k forks source link

DEPRECATED: Cannot create a version on the v1beta1 endpoint. Please use v1 #43

Open apanagar opened 7 years ago

apanagar commented 7 years ago

Hi - Thanks for this great work. I was able to train the model I needed with fantastic results. I'm now trying to get it into Google ML

I was able to train and export my model, and I tried the following command

python server/tools/upload-model.py --bucket pix2pix-model --model_name pix2pix_model --model_dir models/myModel --credentials credential.json

and I got the following output

creating version v1
uploading export.meta.gz
uploading export.index.gz
uploading export.data-00000-of-00001.gz
Traceback (most recent call last):
  File "server/tools/upload-model.py", line 101, in <module>
    main()
  File "server/tools/upload-model.py", line 85, in main
    operation = ml.projects().models().versions().create(parent=model_path, body=version).execute()
  File "/home/apanagar/pix/lib/python3.5/site-packages/oauth2client/_helpers.py", line 133, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/home/apanagar/pix/lib/python3.5/site-packages/googleapiclient/http.py", line 840, in execute
    raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 400 when requesting https://ml.googleapis.com/v1beta1/projects/xxxxx-xxxx-123456/models/pix2pix_model/versions?alt=json returned "DEPRECATED: Cannot create a version on the v1beta1 endpoint. Please use v1.">

Am I doing something wrong? I tried changing the v1beta1 to v1 in the script but that resulted in another error. Apologies, I'm just getting started with Google's Cloud ML so it's possible I'm missing something obvious.

apanagar commented 7 years ago

Ok, a little bit progress I changed v1beta1 to v1 and added --runtime_version 1.2, now it seems to be crashing with the following error

googleapiclient.errors.HttpError: <HttpError 400 when requesting https://ml.googleapis.com/v1/projects/xxxxx-xxxxx-123456/models/pix2pix_model/versions?alt=json returned "Field: version.deployment_uri Error: With v1 endpoint, the model directory gs://pix2pix-model/pix2pix_model-v1/ is expected to contain exactly one of the following: 'saved_model.pb' file or 'saved_model.pbtxt' file. Please use SavedModel.

the model I generated using the export instructions created a directory containing these files

checkpoint  export.data-00000-of-00001  export.index  export.meta  options.json

however the original trained model checkpoint directory contains a pbtxt file. Did I export the model incorrectly?

Bergvca commented 6 years ago

I'm having the same problem. Apparently cloud ML wants models saved with SavedModel.

I tried adding this to pix2pix.py but don't understand how the signature should look like. I added the following to the export code:

builder = tf.saved_model.builder.SavedModelBuilder(new_outputdir)
builder.add_meta_graph_and_variables(sess,
                                       [tf.saved_model.tag_constants.SERVING],
                                       signature_def_map=None,
                                       assets_collection=None)
 builder.save() 

However when adding this to cloud ml I get the error:

The version is not ready for prediction and cannot be set as the default version.

Some info from the cloud ml page:

Change from export_meta_graph to SavedModel for exporting models

In Beta, Cloud ML Engine supported the older TensorFlow graph serialization format generated by export_meta_graph (tf.train.export_meta_graph) for deploying your models. That format is no longer supported. Now your models must be deployed using the newer SavedModel (tf.saved_model) format.