-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can I check if my tensorflow model is compatible #317
Comments
Hi @odinsbane,
|
Thank you for the quick response. I can easily put together an example from what I have. Maybe you can help me before I start uploading things. I have a tensorflow model. There is one input and three outputs. I made a version with one output to get it to work. I don't mind changing the format, either .h5 or directory. This is the code I used to build the model.
This is the output.
If I try using a .h5 file (same mode, I load it in python, then save it with save_format="h5") I get a different error. What do you think is the best way to proceed? |
I tried a version of the build script using an h5 version of the tensorflow model, and everything seems to be working. It created a zip file and I am trying to upload the zip file to bioimage.io (or zenodo via bioimage.io) which suites my purpose well. So maybe the sole purpose of this issue is, why doesn't the directory format work? |
Ok, note that in this case you need to set the weight format to
I think that we are expecting a zip file of the weights here. It should work if you zip the folder with the weights and then pass the filepath of the zipped file to the |
That worked! I think it worked because it created the bioimage-model zip file. It could be helpful if the documentation said that the directory needs to be zipped, that they names in the weights spec page are the values that should passed to the weights_spec parameter. The "weights_spec" appears to be generated documentation (similar to Tensorflow doc's?) |
Ok, thanks for checking!
I agree, it would be good to update this. (And indeed the weight spec documentation is autogenerated.) I am not so familiar with the doc generation procedure, maybe @FynnBe could have a look. |
I can close this issue, but I just want to make sure. Is there another way to test the model? For me I had to work through fixing the data, then fixing the model, then fixing the data. Did you add the h5 support recently? |
Let's leave it open until the documentation is updated.
Once you have created the model you can test it via the
No, that has been there for a while. |
Okay, I finally got around to using the bioimageio test-model! If I use the h5 version of the saved tensorflow model, then the tests pass. When I use the .zip file of the folder saved model I get an error.
|
@odinsbane could you share the created zip folder, any additional files that should be included in it, but are not, and your updated |
It's a large file, so I am looking at uploading it or making an example. I think though, looking at the temp folder the problem is the way the file has been zipped.
Maybe I need to zip the contents and remove the top-level folder? |
that's probably it. 👍 I can't improve this right now, but here are some notes from looking into it briefly, if someone else wants to tackle it already: We should improve the TF Moder adapter here: Lines 65 to 66 in bc25746
here We potentially unzip nested zip files (calling self.require_unzipped twice, which we probably shouldn't) We also implicitly assume the use of tensorflow 1: Lines 34 to 35 in bc25746
Maybe https://www.tensorflow.org/api_docs/python/tf/saved_model/save is a relevant reference for updating this part. |
I have a lot of uncertainty in this process. It would be nice if I can debug the various steps.
I have a model, I load images as [t, c, z, y, x] and then I convert them to batches [b, c, z, y, x] using tiling, then I process the batches with the model. The output is then reconstructed into a prediction.
I think I setup the data ok because I don't get a random assertion error about the shape, but when I try to build the model, I get an error that my tensorflow directory is a directory.
What do I need to do to specify the weight type?
According to this, bioimageio_weights_spec I should be able to use a tensorflow folder, but it isn't clear.
The text was updated successfully, but these errors were encountered: