mdietrichstein / tensorflow-open_nsfw

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

export_model.py generates a protobuf unreadable in tensorflow #4

Closed simo-lab closed 6 years ago

simo-lab commented 6 years ago

I run export_model.py and I've got a protobuf saved, but when I've tried to import the model with Tensorflow I got an "Invalid GraphDef" error.

mdietrichstein commented 6 years ago

Hey @Pacana78

Which version of tensorflow are you using for importing and exporting the model?

simo-lab commented 6 years ago

Hey @mdietrichstein sorry for the late reply. I am using tf version 1.3.0

mdietrichstein commented 6 years ago

I can't seem to reproduce this problem with tensorflow 1.3.0.

I have exported the model with export_model.py and imported it with tf.saved_model.loader.load in another script. Didn't get any error...

Do you have some more details for me, e.g. the code you are using to import the model, python version, platform (Linux, Windows, ...)?

simo-lab commented 6 years ago

I'm using Python 2.7.12 inside a docker. Here's the version

docker version

Client: Version: 17.09.0-ce API version: 1.32 Go version: go1.8.3 OS/Arch: darwin/amd64

Server: Version: 17.09.0-ce API version: 1.32 (minimum version 1.12) Go version: go1.8.3 OS/Arch: linux/amd64 Experimental: true

After I've exported the model using export_model.py, I use these instructions in Go to import the saved model

graph := tf.NewGraph()
if err := graph.Import(model, "ResNet_50_1by2_nsfw"); err != nil {
   //here I get an Invalid GraphDef error
   log.Fatal(err)
}

Thanks

mdietrichstein commented 6 years ago

Thanks for the additional information @Pacana78

I see now where the problem is. The export_model.py script exported a SavedModel which does not seem to be compatible for loading via graph.Import.

I have added a new script (tools/export_graph.py) which exports standard graphdef and checkpoint files.

Let me know if those work for you.