or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

components.mdindex.mdremote-monitoring.mdstatistics.mdstorage.mdui-server.md
tile.json

ui-server.mddocs/

UI Server Management

The UI Server is the central component that manages the web-based monitoring interface for DeepLearning4J training processes. It provides a singleton server instance that coordinates data visualization and remote monitoring capabilities.

Core Server API

UIServer

The main abstract class for UI server management.

public abstract class UIServer {
    // Get singleton UI server instance
    public static synchronized UIServer getInstance();
    
    // Server information
    public abstract String getAddress();
    public abstract int getPort();
    
    // Storage management
    public abstract void attach(StatsStorage statsStorage);
    public abstract void detach(StatsStorage statsStorage);
    public abstract boolean isAttached(StatsStorage statsStorage);
    public abstract List<StatsStorage> getStatsStorageInstances();
    
    // Remote listener functionality
    public abstract void enableRemoteListener();
    public abstract void enableRemoteListener(StatsStorageRouter statsStorage, boolean attach);
    public abstract void disableRemoteListener();
    public abstract boolean isRemoteListenerEnabled();
    
    // Server lifecycle
    public abstract void stop();
}

PlayUIServer Implementation

The concrete implementation using the Play Framework.

public class PlayUIServer extends UIServer {
    public static final int DEFAULT_UI_PORT = 9000;
    
    public PlayUIServer();
    public void runMain(String[] args);
}

Usage Examples

Basic Server Setup

import org.deeplearning4j.ui.api.UIServer;
import org.deeplearning4j.ui.storage.InMemoryStatsStorage;

// Get the singleton UI server instance
UIServer uiServer = UIServer.getInstance();

// Create storage for statistics
InMemoryStatsStorage statsStorage = new InMemoryStatsStorage();

// Attach storage to the UI server
uiServer.attach(statsStorage);

// Server is now accessible at http://localhost:9000
System.out.println("UI Server running at: " + uiServer.getAddress());

Managing Multiple Storage Instances

import org.deeplearning4j.ui.api.UIServer;
import org.deeplearning4j.ui.storage.InMemoryStatsStorage;
import org.deeplearning4j.ui.storage.FileStatsStorage;

UIServer uiServer = UIServer.getInstance();

// Attach multiple storage instances
InMemoryStatsStorage memoryStorage = new InMemoryStatsStorage();
FileStatsStorage fileStorage = new FileStatsStorage(new File("training-stats.db"));

uiServer.attach(memoryStorage);
uiServer.attach(fileStorage);

// Check attached storage instances
List<StatsStorage> attachedStorage = uiServer.getStatsStorageInstances();
System.out.println("Number of attached storage instances: " + attachedStorage.size());

// Detach when no longer needed
uiServer.detach(memoryStorage);

Remote Monitoring Setup

import org.deeplearning4j.ui.api.UIServer;
import org.deeplearning4j.api.storage.impl.RemoteUIStatsStorageRouter;

UIServer uiServer = UIServer.getInstance();

// Enable remote listener with in-memory storage
uiServer.enableRemoteListener();

// Or with custom storage router
RemoteUIStatsStorageRouter remoteRouter = new RemoteUIStatsStorageRouter("http://remote-ui-server:9000");
uiServer.enableRemoteListener(remoteRouter, true);

// Check if remote listener is enabled
if (uiServer.isRemoteListenerEnabled()) {
    System.out.println("Remote monitoring is active");
}

// Disable when done
uiServer.disableRemoteListener();

Module Configuration

UIModule Interface

Interface for creating custom UI modules and extensions.

public interface UIModule {
    List<Route> getRoutes();
    List<Route> getCallbacks();
    String getMenuText();
    String getTitle();
}

Route Configuration

HTTP route definitions for UI endpoints.

public class Route {
    public Route(String route, HttpMethod httpMethod, FunctionType functionType, 
                 String functionString, String id);
    
    public String getRoute();
    public HttpMethod getHttpMethod();
    public FunctionType getFunctionType();
    public String getFunctionString();
    public String getId();
}

HTTP Methods and Function Types

public enum HttpMethod {
    GET, POST, PUT, DELETE
}

public enum FunctionType {
    Supplier, Function, BiFunction
}

Server Lifecycle

Starting the Server

The UI server starts automatically when getInstance() is first called. The default port is 9000.

Stopping the Server

UIServer uiServer = UIServer.getInstance();

// Stop the server when application shuts down
uiServer.stop();

Custom Port Configuration

import org.deeplearning4j.ui.play.PlayUIServer;

// Create server with custom port
PlayUIServer server = new PlayUIServer();
server.runMain(new String[]{"--uiPort", "8080"});

Utility Functions

Browser Integration

public class UiUtils {
    public static void tryOpenBrowser(String path, Logger log);
    public static void openBrowser(URI uri) throws Exception;
}

Usage example:

import org.deeplearning4j.ui.UiUtils;

UIServer uiServer = UIServer.getInstance();
String serverAddress = uiServer.getAddress();

// Attempt to open browser automatically
UiUtils.tryOpenBrowser(serverAddress, LoggerFactory.getLogger(MyClass.class));

Internationalization

I18N Support

public class I18N {
    // Methods for internationalization support
    public static String getMessage(String key);
    public static String getMessage(String key, Object... args);
}