Giter Club home page Giter Club logo

trinity's Introduction

Trinity

Maven Build Gradle Build

Explainable AI (XAI) Analysis and Visualization tool

Trinity City

Trinity provides performance analysis and XAI tools ideal for Deep Learning systems or other models performing complex classification or decoding. Trinity does this through a combination of different interactive 3D projections that are hyper-dimensional aware. (Vectors of Vectors)

Hyperspace

Hyperspace Projection Trinity's Hyperspace view provides a 3D scatter plot with automatic 2D projections of feature/factor data. The dimensional combinations can be instantly switched to rapidly search through hyper-dimensional space. The user can pan, rotate and zoom either the 3D camera or the points themselves. The scatter points are interactive allowing the user to select individual points to bring up the associated data/imagery with that feature.

Hypersurface

TrinityBCI-Hypersurface Trinity can visualize higher dimensional inputs (before decoding) as a 3D surface. Hypersurface view provides analyst insight into what inputs correlate strongest with a decoding/classification result. This view is synchronized with the same FeatureVectors and Timeline as the Hyperspace viewpoint.

Projections and Manifolds

TrinityBCI-UMAP-Yule Trinity provides a fast parallelized UMAP tool with a simple to use GUI to project the hyper-dimensional embeddings down to an arbitrary lower dimensional space. This allows analysts to project approximate manifolds as 3D clusters.

Data Formats

Trinity primarily speaks JSON and has a collection of serializable JSON message objects that can be imported. The primary message that most applications will leverage is the FeatureVector. Example:

{
    "messageType": "feature_vector",
    "messageId": 0,  #optional long value for order or id of data point
    "data": [-0.4232191175986961, -0.5031443592838056, 0.30497221256679125,
        0.4157550505277444, -0.46174460409303325, -0.12950797668733202,
        0.6323170694189965, 0.20112482321095512, -0.0770502704073328,
            #... some arbitrarily long vector of embeddings...#
        -0.021781132983331605, 0.2855062868586593, -0.11389146262348109,
        -0.4338320677142379, 0.14545007041168245, 0.34325194689681915
    ],
    "score": -2.753245759396493, #Typically the classification score provide by model but could be any floating point value you choose
    "pfa": 0.0008605957637858228, #Auxiliary floating point between 0 and 1 typically associated with a probability
    "label": "some_object",  #human readable string that is categorical
    "bbox": [0.0, 0, 16.0, 0], #optional Coordinate set typically used for Bounding box identification but could be used for anything
    "imageURL": "/media/images/video_frame_9001.jpg", #image associated with this data point. Supports *.png or *.jpg files. Also supports http based urls
    "layer": 3, #Typically the layer of the model the embeddings were taken from but can represent any Integer based hierarchal info
    "metaData" : { # Totally optional info hash map
        "some name" : "some value",
        "optional" : "string name/value pairs that provide additional info"
    }
}

FeatureVector objects can be sent to Trinity as a stream using ZeroMQ. The ZeroMQ connection is configured from the Data UI panel. Large collections of FeatureVector objects can be loaded at once as a file drag and drop using the FeatureCollection JSON object. The FeatureCollection object is simply an array of FeatureVector objects with a type field that Trinity uses to detect file type at Drag and Drop

{   "type": "FeatureCollection",
    "features": [
        ...boat load of FeatureVector objects
    ]
}

Trinity will auto colorize the data in both the Hyperspace and Projections views by the label field. It uses a rotational color map that has 12 predefined colors. Colors can be reassigned to color gradients using score, layer, pFa or even raw coordinate position via the GUI. The user can create custom color maps by label using the LabelConfig message. Labels can be explicitly colored by RGBA hex code. The LabelConfig also supports Java compatible regular expression wildcards. A LabelConfig json file can be simply dragged and dropped onto the Trinity application and it will automatically update the views.

{
    "messageType": "label_config",
    "wildcards" : {
        "human_.*":"#0000FFFF",
        "human_Original.*":"#FFFF00FF",
        "chatGPT_.*":"#FF0000FF",
        "chatGPT_Original.*":"#00FF00FF"
    },
    "clearAll" : "false"
}

Example Use Cases

Trinity has been applied to a series of use cases including:

Deep Learning Object detection models Trinity-Competency-UMAP

COVID gene/tissue classification TrinityCOVIDTissueGeneSequenceUMAP-Yule

Brain Computer Interface decoders TrinityBCI-Hyperspace

Large Language Model (ChatGPT) Embeddings Analysis TrinityHumanVsChatGPTEmbeddings-UMAP-Yule

Project contributors:

airplanelaugh

  • Sean M Phillips
  • Melanie Lockhart
  • Samuel Matos
  • Gene Whipps
  • Griffin Milsap
  • David Newcomer
  • Luis Puche Rondon

Building and Running

You can build with either Maven or Gradle with a modern version of Java (>=17). There's already a set of scripts for building and running if you use a Jetbrains IDE or Netbeans to facilitate a cold start on the project. To run the project from a jar after building, you can take a look at the scripts directory to get you started. Otherwise, make sure to use at least -Dprism.maxvram=2G on your JVM parameters when starting it up. For JLink/JPackage builds those JVM args are baked in already into the packages.

Troubleshooting

Execution permissions might need to be needed to run the JPackage, JLink, or Native builds depending on which system you're running from. For example on OSX systems you might get Unknown error: 111 or launch errors, hence you need to allow the app through GateKeeper via xattr -r -d com.apple.quarantine /path/to/Trinity.app. You might also need to add execution permissions in some cases via chmod +x /path/to/Trinity.app/Contents/MacOS/Trinity when using the JPackage build.

trinity's People

Contributors

birdasaur avatar samypr100 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

trinity's Issues

Interactive Point Distance Tool

Add interaction feature to Projection3D pane so that users can click on points and see calculated distances.
First cut will use keyboard controls to select either points or groups. (Click vs control click)
Second cut will provide UI overlay options to simplify selection and provide additional Distance metric values.

  • Should provide options to compute point to point and point to group.
  • Point to point will render single line connecting the end points.
    - [ ] Point to group will render lines from the first point selected to each point in the grouping.
    - [ ] Investigate Group to Group line distances
  • Groups will be defined by being part of a label cluster/manifold and distances will be Euclidean.
  • Investigate 3D line vs 2D overlay line connections. (might be nice to have both options with 2D lines being dashed and transparent. Oh we could use the 2D version as a cool highlight effect when you hover or select that node or 3D link)
  • Implement additional UI tab in Manifolds pane to manage current distance measurements.

"Save as Image" feature seems broken

I dragged-and-dropped the feature collection JSON (below) to Trinity, and tried to use the "Save as Image" feature to capture a screenshot of the resulting points, but it looks like what's saved is an image (below) of the menu with "Save as Image" button. I assume that this is not the intended behavior of "Save as Image"?

test

FeatureCollection JSON: https://pastebin.com/mgWwASwc

Add PCA Projections tools

Some people prefer PCA for their dimension reduction needs. Apache Math Commons provides straight forward PCA and SVD functions out of the box.

  • add PCA/SVD Tab to Manifold Controls

Image Based Hyperbolic Navigator

Build UI tool for ingesting and rapidly navigating imagery from a collection based on human understandable axes.
Tool should provide the user with multiple rendered axes by which they can slide or hop through the latent space, either via a target reticule or polar angle system.
The Image/Content associated with the embedding vector for the current location in the coordinate space should be displayed in a portrait view.
This update should occur instantly to allow the user to gain a "sense of something" from navigating the latent space.

Easy way to Clear all Callouts

Currently the only way to clear a call out from the screen is by double clicking its title bar. (Or swiping it on a touch screen)
This can be tedious when many callouts have been opened and then need to be cleared.

  • Add event for closing all callouts so they can be closed by application events in the future
  • Add event for closing a particular callout (instance)
  • Add GUI mechanism to close all open callouts in Hyperspace3D by adding menu option to custom animated context menu.
  • Add GUI mechanism to close all open callouts in Projections3D views by adding menu option to context menu
  • Add Right Click style context menu popup to callout title bar.
  • Add ContextMenu option to close that callout instance
  • Add ContextMenu option to close all instances (fire close all event)

Manifold Auto-Metric Upgrade

Add support that leverage various distance measurements from UMAP code in the following ways:

  • Hover/Select a point and select a manifold and see the measurement metrics in an overlay
  • Implement mode where new points added to the scene are automatically measured
  • Implement setpoint threshold system to red flag new points that are out of band
  • Implement new Manifold Message with Json format including the 3D hull of points (default is sphere)

Ultimate Objective is to have new points come in (over ZeroMQ lets say) and have them automatically trigger these events/actions/visuals.

ARM64 Support

  • Apple Silicon Support
  • Initially maven jars and gradle jpackage support would be great
  • Universal packaging for OSX is a bonus

Group wise Distances

Investigate group distance measurements...

  • Add distance measure from point to nearest manifold hull point
  • Check to see if a point is Inside or outside a manifold hull
  • Calculate "centroid" of hull based on average hull point locations (x,y,z of each point averaged)
  • Calculate "centroid" based on median
  • Calculate manifold bounding box
  • Make a new callout for status of point based on the above checks and a user set threshold

First Release

  • Update CI to make Release Artifacts
  • Provide initial Changelog

Dimension Index Spinners

Current Dimension Indices are maintained using slider controls. This has proven to be unwieldy and take up too much space.

image

Update the GUI and observer logic to use editable Spinners instead of sliders.

SHAPley Analysis and JSON Import Support

An effective method for evaluating model performance, especially those that process images as input, are to compute SHAP values for the input vector. This results in a vector of SHAPley values that measure how strongly a given input dimension (ie pixel) correlates with or affected the resulting output.

  • Upgrade Trinity to support the importation of a dedicated SHAP JSON format
  • JSON Format should connect SHAPley vector scores with input source file (local path)
  • Render Hypersurface using SHAPley values as height map
  • Colorize 3D surface using original RGB from input source file image
  • optionally color surface by SHAPley value as heat map

Tokenized ChatGPT Embeddings Support

Provide data/reader support for a custom JSON format that provides parallel arrays of embeddings aligned with ChatGPT generated text tokens.
Convert to FeatureVector objects and load into Hyperspace view.

Dimensional Label Support

Standardize assigning labels to feature vector dimensions so that Hyperspace view can automatically relabel axes as dimensions are updated. There is already support built in to the Hyperspace view to do this but its thus far only utilized by explicit file loading activities.

  • Update FeatureCollection and LabelConfig messages to allow optional dimensionLabels array.
  • Update FeatureVector event handler to handle optional dimensionLabels data
  • Hyperspace is updated whenever Dimension Label message is received
  • new UI component that lists all dimensional labels in order
  • allow direct text editing of individual dimension labels.
  • Add/Remove individual dimensional labels. (default string is just "Factor")
  • Clear all dimensional labels button

Distance object Color not updating on change

Related to #35

After a Distance object has been created the color of the 3D line that represents it can be changed using a color picker. However when the color value in the control is altered the Distance object's color is not immediately updated. When selecting a different Distance object in the list view, the previously changed color is then rendered. This implies that either the distance change event is not being fired or the listeners are not hooked in, or possibly the global map of distance objects is not being updated in a timely manner relative to the event handling.

This behavior has been observed in the Projections 3D pane but may also be present in the Hyperspace3D pane.

Automate PDF Generation

Auto generate src/main/resources/edu/jhuapl/trinity/wiki/Trinity.pdf during build to be able to remove it from version control

Linux Native build

Linux native build via GraalVM is currently failing due to improper setup. Ideally we can add support.

Stackable Parameter Radar Upgrade

Current Parameter Radar implementation only supports a single data point using Radar Sector plotting approach:

image

  • Upgrade so that the parameter radar is "stackable", ie.. when engaged each subsequent new data point is added to the chart instead of replacing so users can visualize differences.
  • Add toggle button to engage stacking feature
  • Upgrade Parameter chart labels to draw from new Dimension labeling system when available
  • Fix plotting so that Radar polygon options work. (may need to upgrade Charts library version)
  • Upgrade Projections3D pane so Parameter RADAR is enabled for this view. Allow user to click on projected points and see the hyper-dimensional data associated with it.

Concave Hull Support

Implement 3D Concave Hull generator that uses Convex Hull (or some other set of points) as input.
Since typically in a non trivial case there will be multiple possible concave hulls derivable from a tolerance variable, make this variable accessible to the user.
Make 3D view that generates a collection of possible Concave Hulls based on a discretization across the tolerance variable.
Let the user select the hull they prefer.
Maybe make it a 3D carousel that rotates for the lulz.

Dedicated Clustering Tool

Currently clustering is accessible via the manifolds pane and overly constricted. This is preventing new options and parameters to be exposed to the GUI.

  • Separate the current clustering options by combining with manifold geometry editor pane
  • Add DBSCAN support
  • Add KMeans support
  • Add Kmedoids support
  • Add Affinity Propagation Support
  • Update Projection Config record class to account for all various options for above
  • Tie in GUI controls for all config options

Upgrade Point Distance Tools to support group-wise metrics

Currently the Projections view supports a UMAP tool and a Convex Hull implementation.

  • Upgrade Convex Hull tools so that it can easily identify clusters of points based on label

  • Add tracker for Manifold objects (like Distance UI tab)

  • Implement new Manifold JSON object, message and file support for 3D hull of points

  • Groups will be pulled from manifolds generated from Hull Geometry tab

    Finish implementing Visibility checkbox for distance connectors moved to #35

  • Point to group will render lines from the first point selected to closest point in the grouping.

Investigate Group to Group line distances moved to #37

Audio Clip Support for Feature Vectors

  • Update FeatureVector interactions to support audio clip as source of FeatureVector
  • Create small audio playback widget for Feature Callouts
  • Create larger "audio console" pane similar to Text Console
  • Investigate rendering audio clips on hypersurface

Image FFT with 3D projection

Investigate applying FFT to image pixels. If possible apply to a series of consecutive frames (from a video).
Project resulting amplitude or deltas as 3D surface.

Implement Trajectory Manager

  • Implement trajectory tracking logic similar to how Distances are managed.
  • Add trajectory list manager UI similar to Distances UI
  • Each new file that is added to the view will automatically create a new Trajectory in the tracker.
  • New trajectories will use the filename as the Trajectory Label by default
  • Selecting a trajectory in manager will fire a new Active Trajectory event
  • Trajectories Color and Visibility can be modified from tracker
  • Hyperspace view will be updated to plot trajectories as static 3D polylines
  • Projections view will be updated to plot trajectories as static 3D polylines

Add Optional Text field to data callout

Currently the data callouts have a few fixed fields common to most applications and a general metaData hashmap catchall.
Reason surges in Large Language Model applications show a value to having a dedicated fixed field for a small Text blurb.
Currently users must add their text as a metaData field which doesn't format the text well.

Add a TextArea section to the callouts as a new TitledPane. Default to collapsed.
Restrict the TextArea to a reasonable width and height such that the user can scroll the text inside this node.
Add a clickable button that will popup the entire Text into a larger floating view for easier reading for larger blurbs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.