mjtb49 / StrongholdTrainer

MIT License
22 stars 10 forks source link

Shift model loading from DL4J to purely TensorFlow #10

Closed fsharpseven closed 3 years ago

fsharpseven commented 3 years ago

Also include a utility script to convert Keras to saved model format. @mjtb49 mentioned doing this, so I'm opening this as a draft PR. Probably needs refactoring and testing. A version that actually runs in a non-dev fabric environment is on DasBundesland/StrongholdTrainer:zip-tf-loading.

fsharpseven commented 3 years ago

A note on TensorFlow model loading TF can't (to my knowledge) load a SavedModel export directory from within a JAR. This is because methods like TF_LoadSessionFromSavedModel are implemented in C++ with Java bindings and as such require the files to exist on the filesystem. The problem is that JAR file entries don't actually exist on the filesystem because they are archived as resources in the JAR. This problem is solvable by storing the directory as a ZIP archive in the JAR, then extracting that ZIP into something like .minecraft/config/stronghold_trainer/model, which is roughly implemented on my zip-tf-loading branch. A fuller system for dynamic model loading is on dynamic-model-loading.

fsharpseven commented 3 years ago

Closed in favor of #11