Select Git revision
experiment1.py
DeepLearningVersionSelector.java 6.42 KiB
package plugins.danyfel80.deeplearningdownloader;
import java.awt.event.ActionListener;
import java.awt.event.WindowListener;
import java.io.IOException;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.bioimageanalysis.icy.deeplearning.versionmanager.loading.LibraryLoadingStatus;
import org.bioimageanalysis.icy.deeplearning.versionmanager.version.AvailableDeepLearningVersions;
import org.bioimageanalysis.icy.deeplearning.versionmanager.version.DeepLearningVersion;
import icy.gui.dialog.MessageDialog;
import icy.main.Icy;
import icy.plugin.PluginLauncher;
import icy.plugin.PluginLoader;
import icy.preferences.XMLPreferences;
import icy.system.IcyHandledException;
import icy.util.StringUtil;
import plugins.adufour.blocks.lang.Block;
import plugins.adufour.blocks.util.VarList;
import plugins.adufour.ezplug.EzPlug;
import plugins.adufour.ezplug.EzStoppable;
import plugins.adufour.ezplug.EzVarText;
import plugins.adufour.vars.lang.VarBoolean;
import plugins.adufour.vars.lang.VarString;
/**
* This plugin allows users to select the TensorFlow version to load in memory.
* Just select one of the available versions and click the "play" button to load the library.
* Please keep in mind that only one version of TensorFlow can be loaded per Icy
* execution. An Exception will be thrown if a TensorFlow version tries to loaded after another version has already been loaded.
*
* @author Daniel Felipe Gonzalez Obando and Carlos Garcia Lopez de Haro
*/
public class DeepLearningVersionSelector extends EzPlug implements EzStoppable, Block
{
private EzVarText varInVersion;
private final static Map<String, DeepLearningVersion> versions;
static
{
versions = AvailableDeepLearningVersions.loadCompatibleOnly().getVersions().stream()
.collect(Collectors.toMap(
v -> v.getEngine() + "-" + v.getPythonVersion() + "-"
+ (v.getMode().toLowerCase().equals("cpu") ? "cpu" : "cpu-gpu"),
Function.identity()));
}
/**
* Main routine launching this plugin.
*
* @param args
*/
public static void main(String[] args)
{
Icy.main(args);
PluginLauncher.start(PluginLoader.getPlugin(DeepLearningVersionSelector.class.getName()));
}
@Override
protected void initialize()
{
String[] versionStrings = versions.keySet().stream().sorted().toArray(String[]::new);
varInVersion = new EzVarText("Version", versionStrings, getDefaultVersionIndex(versionStrings), false);
addEzComponent(varInVersion);
}
private VarString varInBlockVersion;