Imagej-tensorflow now with command to change TensorFlow library version / switch to GPU

Hi all,

the newest imagej-tensorflow version (1.1.4), out since a few weeks, contains a command which might be interesting to some of you: It change the version of the TensorFlow Java bindings for you.

Usage

In the most recent CSBDeep version this is already integrated. Here is how to use it:

  1. Open Edit > Options > TensorFlow...
  2. Choose the TensorFlow version matching your system / model
    image
  3. Wait until the library is downloaded and installed (a popup will tell you when it’s done)
  4. Restart Fiji
  5. Run any CSBDeep plugin

That’s it!

What to change for a plugin depending on imagej-tensorflow

If you are developing a plugin which is using imagej-tensorflow (ping @ctrueden) , you can add these lines:

...
	@Parameter
	TensorFlowService tensorFlowService;

	@Parameter
	CommandService commandService;

	public void run() {
		tensorFlowService.loadLibrary();
		if (tensorFlowService.getStatus().isLoaded()) {
			log(tensorFlowService.getStatus().getInfo());
		} else {
			logService.error("Could not load TensorFlow. Check previous errors and warnings for details.");
			JOptionPane.showMessageDialog(null,
					"<html>Could not load TensorFlow.<br/>Opening the TensorFlow Library Management tool.</html>",
					"Loading TensorFlow failed",
					JOptionPane.ERROR_MESSAGE);
			commandService.run(TensorFlowLibraryManagementCommand.class, true);
		}

	...
	}
...

This snippet loads the library installed by the TF library management command, checks which version is loaded and, if the library could not be loaded for some reason, opens the TF library management command. This will give more information why the loading failed and give the user the chance to switch the version.

Best,
Debo

4 Likes