From 62f6d488632ab71af910f04a372da0d183e66d94 Mon Sep 17 00:00:00 2001
From: carlosuc3m <100329787@alumnos.uc3m.es>
Date: Fri, 22 Nov 2024 19:44:33 +0100
Subject: [PATCH] improve html display
---
.../communication/model/EfficientSAM.java | 25 +--
.../model/EfficientViTSAML0.java | 41 ++--
.../model/EfficientViTSAML1.java | 42 ++--
.../model/EfficientViTSAML2.java | 39 ++--
.../model/EfficientViTSAMXL0.java | 38 ++--
.../model/EfficientViTSAMXL1.java | 38 ++--
.../samj/communication/model/SAM2Large.java | 29 +--
.../samj/communication/model/SAM2Small.java | 29 +--
.../samj/communication/model/SAM2Tiny.java | 28 +--
.../samj/communication/model/SAMModel.java | 58 ++++-
src/main/java/ai/nets/samj/gui/HTMLPane.java | 199 ++++++++++--------
src/main/java/ai/nets/samj/gui/HTMLPane2.java | 110 ++++++++++
.../samj/gui/components/ModelDrawerPanel.java | 60 +++++-
13 files changed, 452 insertions(+), 284 deletions(-)
create mode 100644 src/main/java/ai/nets/samj/gui/HTMLPane2.java
diff --git a/src/main/java/ai/nets/samj/communication/model/EfficientSAM.java b/src/main/java/ai/nets/samj/communication/model/EfficientSAM.java
index 8017d19..6a84692 100644
--- a/src/main/java/ai/nets/samj/communication/model/EfficientSAM.java
+++ b/src/main/java/ai/nets/samj/communication/model/EfficientSAM.java
@@ -76,14 +76,6 @@ public void error(String text) {
*/
public static final String INPUT_IMAGE_AXES = "xyc";
- private static final String HTML_DESCRIPTION = "EfficientSAM: Leveraged Masked Image Pretraining for Efficient Segment Anything
"
- + "Weights size: 105.7 MB
"
- + "Speed: 6th out of 6
"
- + "Performance: 1st out of 6
"
- + "GitHub Repository: https://github.com/yformer/EfficientSAM
"
- + "Paper: EfficientSAM: Leveraged Masked Image Pretraining for Efficient Segment\n"
- + "Anything";
-
private static final String CAUTION_STRING = "
CAUTION: This model is computationally heavy. It is not recommended to use it on lower-end computers.
"; @@ -91,6 +83,15 @@ public void error(String text) { * Create an instance of the model that loads the model and encodes an image */ public EfficientSAM() { + this.isHeavy = true; + this.fullName = "EfficientSAM: Leveraged Masked Image Pretraining for Efficient Segment Anything"; + this.githubLink = "https://github.com/yformer/EfficientSAM"; + this.paperLink = "https://arxiv.org/pdf/2312.00863.pdf"; + this.githubName = "https://github.com/yformer/EfficientSAM"; + this.paperName = "EfficientSAM: Leveraged Masked Image Pretraining for Efficient Segment"; + this.speedRank = 3; + this.performanceRank = 3; + this.size = 105.7; this.manager = EfficientSamEnvManager.create(); } @@ -102,14 +103,6 @@ public String getName() { return FULL_NAME; } - @Override - /** - * {@inheritDoc} - */ - public String getDescription() { - return HTML_DESCRIPTION + (!this.isInstalled() ? SAMModel.HTML_NOT_INSTALLED : CAUTION_STRING); - } - @Override /** * {@inheritDoc} diff --git a/src/main/java/ai/nets/samj/communication/model/EfficientViTSAML0.java b/src/main/java/ai/nets/samj/communication/model/EfficientViTSAML0.java index ec086fe..3f42806 100644 --- a/src/main/java/ai/nets/samj/communication/model/EfficientViTSAML0.java +++ b/src/main/java/ai/nets/samj/communication/model/EfficientViTSAML0.java @@ -76,31 +76,31 @@ public void error(String text) { * Axes order required for the input image by the model */ public static final String INPUT_IMAGE_AXES = "xyc"; - - private static final String HTML_DESCRIPTION = "EfficientViT-SAM smallest version (L0)CAUTION: This model is computationally heavy. It is not recommended to use it on lower-end computers.
"; + public static final String INPUT_IMAGE_AXES = "xyc"; /** * Create an instance of the model that loads the model and encodes an image */ public SAM2Large() { + this.isHeavy = true; + this.fullName = "SAM-2: Segment Anything Model 2 (Large)"; + this.githubLink = "https://github.com/facebookresearch/segment-anything-2"; + this.paperLink = "https://ai.meta.com/research/publications/sam-2-segment-anything-in-images-and-videos/"; + this.githubName = "https://github.com/facebookresearch/segment-anything-2"; + this.paperName = "SAM 2: Segment Anything in Images and Videos"; + this.speedRank = 3; + this.performanceRank = 3; + this.size = 155.9; this.manager = Sam2EnvManager.create(Sam2EnvManager.DEFAULT_DIR, "large"); } @@ -102,14 +101,6 @@ public String getName() { return FULL_NAME; } - @Override - /** - * {@inheritDoc} - */ - public String getDescription() { - return HTML_DESCRIPTION + (!this.isInstalled() ? SAMModel.HTML_NOT_INSTALLED : CAUTION_STRING); - } - @Override /** * {@inheritDoc} diff --git a/src/main/java/ai/nets/samj/communication/model/SAM2Small.java b/src/main/java/ai/nets/samj/communication/model/SAM2Small.java index 41db326..3c74909 100644 --- a/src/main/java/ai/nets/samj/communication/model/SAM2Small.java +++ b/src/main/java/ai/nets/samj/communication/model/SAM2Small.java @@ -75,22 +75,21 @@ public void error(String text) { * Axes order required for the input image by the model */ public static final String INPUT_IMAGE_AXES = "xyc"; - - private static final String HTML_DESCRIPTION = "SAM-2: Segment Anything Model 2CAUTION: This model is computationally heavy. It is not recommended to use it on lower-end computers.
"; - + /** * Create an instance of the model that loads the model and encodes an image */ public SAM2Small() { + this.isHeavy = true; + this.fullName = "SAM-2: Segment Anything Model 2 (Small)"; + this.githubLink = "https://github.com/facebookresearch/segment-anything-2"; + this.paperLink = "https://ai.meta.com/research/publications/sam-2-segment-anything-in-images-and-videos/"; + this.githubName = "https://github.com/facebookresearch/segment-anything-2"; + this.paperName = "SAM 2: Segment Anything in Images and Videos"; + this.speedRank = 3; + this.performanceRank = 3; + this.size = 184.3; this.manager = Sam2EnvManager.create(Sam2EnvManager.DEFAULT_DIR, "small"); } @@ -102,14 +101,6 @@ public String getName() { return FULL_NAME; } - @Override - /** - * {@inheritDoc} - */ - public String getDescription() { - return HTML_DESCRIPTION + (!this.isInstalled() ? SAMModel.HTML_NOT_INSTALLED : CAUTION_STRING); - } - @Override /** * {@inheritDoc} diff --git a/src/main/java/ai/nets/samj/communication/model/SAM2Tiny.java b/src/main/java/ai/nets/samj/communication/model/SAM2Tiny.java index a9df324..39f7109 100644 --- a/src/main/java/ai/nets/samj/communication/model/SAM2Tiny.java +++ b/src/main/java/ai/nets/samj/communication/model/SAM2Tiny.java @@ -74,22 +74,22 @@ public void error(String text) { /** * Axes order required for the input image by the model */ - public static final String INPUT_IMAGE_AXES = "xyc"; - - private static final String HTML_DESCRIPTION = "SAM-2: Segment Anything Model 2CAUTION: This model is" + + " computationally heavy. It is not recommended to use it on lower-end computers.
"; + + protected static String HTML_MODEL_FORMAT = "" + + "Weights size: | " + System.lineSeparator() + + "%s MB | " + System.lineSeparator() + + "
---|---|
Speed: | " + System.lineSeparator() + + "%sth out of 6 | " + System.lineSeparator() + + "
Performance: | " + System.lineSeparator() + + "%sst out of 6 | " + System.lineSeparator() + + "
GitHub Repository: | " + System.lineSeparator() + + "%s | " + System.lineSeparator() + + "
Paper: | " + System.lineSeparator() + + "%s | " + System.lineSeparator() + + "
This model is not installed yet.
"; @@ -56,11 +95,6 @@ public abstract class SAMModel { * @return the axes order required for the input image to the model */ public abstract String getInputImageAxes(); - /** - * - * @return a text describing the model. - */ - public abstract String getDescription(); /** * * @return the {@link SamEnvManagerAbstract} used to install this model @@ -158,6 +192,20 @@ void setImage(final RandomAccessibleInterval