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 ba038f8..0e99eb7 100644 --- a/src/main/java/ai/nets/samj/communication/model/EfficientSAM.java +++ b/src/main/java/ai/nets/samj/communication/model/EfficientSAM.java @@ -49,7 +49,7 @@ public class EfficientSAM extends SAMModel { */ public static final String INPUT_IMAGE_AXES = "xyc"; - + /** * Create an instance of the model that loads the model and encodes an image @@ -67,6 +67,22 @@ public EfficientSAM() { this.manager = EfficientSamEnvManager.create(); } + /** + * Create an instance of the model that loads the model and encodes an image + */ + public EfficientSAM(EfficientSamEnvManager manager) { + 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 = "yformer/EfficientSAM"; + this.paperName = "EfficientSAM: Leveraged Masked Image Pretraining for Efficient Segment"; + this.speedRank = 5; + this.performanceRank = 2; + this.size = 105.7; + this.manager = manager; + } + @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 b131d75..48ed752 100644 --- a/src/main/java/ai/nets/samj/communication/model/EfficientViTSAML0.java +++ b/src/main/java/ai/nets/samj/communication/model/EfficientViTSAML0.java @@ -49,6 +49,8 @@ public class EfficientViTSAML0 extends SAMModel { * Axes order required for the input image by the model */ public static final String INPUT_IMAGE_AXES = "xyc"; + + private static final String ID = "l0"; @@ -65,7 +67,25 @@ public EfficientViTSAML0() { this.speedRank = 3; this.performanceRank = 3; this.size = 139.4; - this.manager = EfficientViTSamEnvManager.create(EfficientViTSamEnvManager.DEFAULT_DIR, "l0"); + this.manager = EfficientViTSamEnvManager.create(EfficientViTSamEnvManager.DEFAULT_DIR, ID); + } + + /** + * Create an instance of the model that loads the model and encodes an image + */ + public EfficientViTSAML0(EfficientViTSamEnvManager manager) { + this.isHeavy = false; + this.fullName = "EfficientViT-SAM smallest version (L0)"; + this.githubLink = "https://github.com/mit-han-lab/efficientvit"; + this.githubName = "mit-han-lab/efficientvit"; + this.paperName = "EfficientViT-SAM: Accelerated Segment Anything Model Without Performance Loss"; + this.paperLink = "https://arxiv.org/pdf/2402.05008.pdf"; + this.speedRank = 3; + this.performanceRank = 3; + this.size = 139.4; + if (!manager.getModelType().equals(ID)) + throw new IllegalArgumentException("The model type should be: " + ID + " vs manager model type: " + manager.getModelType()); + this.manager = manager; } @Override diff --git a/src/main/java/ai/nets/samj/communication/model/EfficientViTSAML1.java b/src/main/java/ai/nets/samj/communication/model/EfficientViTSAML1.java index cdd3938..c7b0354 100644 --- a/src/main/java/ai/nets/samj/communication/model/EfficientViTSAML1.java +++ b/src/main/java/ai/nets/samj/communication/model/EfficientViTSAML1.java @@ -47,7 +47,9 @@ public class EfficientViTSAML1 extends SAMModel { /** * Axes order required for the input image by the model */ - public static final String INPUT_IMAGE_AXES = "xyc"; + public static final String INPUT_IMAGE_AXES = "xyc"; + + private static final String ID = "l1"; /** @@ -63,7 +65,25 @@ public EfficientViTSAML1() { this.speedRank = 3; this.performanceRank = 3; this.size = 190.9; - this.manager = EfficientViTSamEnvManager.create(EfficientViTSamEnvManager.DEFAULT_DIR, "l1"); + this.manager = EfficientViTSamEnvManager.create(EfficientViTSamEnvManager.DEFAULT_DIR, ID); + } + + /** + * Create an instance of the model that loads the model and encodes an image + */ + public EfficientViTSAML1(EfficientViTSamEnvManager manager) { + this.isHeavy = false; + this.fullName = "EfficientViT-SAM smallest version (L1)"; + this.githubLink = "https://github.com/mit-han-lab/efficientvit"; + this.githubName = "mit-han-lab/efficientvit"; + this.paperName = "EfficientViT-SAM: Accelerated Segment Anything Model Without Performance Loss"; + this.paperLink = "https://arxiv.org/pdf/2402.05008.pdf"; + this.speedRank = 3; + this.performanceRank = 3; + this.size = 190.9; + if (!manager.getModelType().equals(ID)) + throw new IllegalArgumentException("The model type should be: " + ID + " vs manager model type: " + manager.getModelType()); + this.manager = manager; } @Override diff --git a/src/main/java/ai/nets/samj/communication/model/EfficientViTSAML2.java b/src/main/java/ai/nets/samj/communication/model/EfficientViTSAML2.java index de9d93e..e9d41a3 100644 --- a/src/main/java/ai/nets/samj/communication/model/EfficientViTSAML2.java +++ b/src/main/java/ai/nets/samj/communication/model/EfficientViTSAML2.java @@ -48,6 +48,8 @@ public class EfficientViTSAML2 extends SAMModel { * Axes order required for the input image by the model */ public static final String INPUT_IMAGE_AXES = "xyc"; + + private static final String ID = "l2"; /** @@ -63,7 +65,25 @@ public EfficientViTSAML2() { this.speedRank = 1; this.performanceRank = 5; this.size = 245.7; - this.manager = EfficientViTSamEnvManager.create(EfficientViTSamEnvManager.DEFAULT_DIR, "l2"); + this.manager = EfficientViTSamEnvManager.create(EfficientViTSamEnvManager.DEFAULT_DIR, ID); + } + + /** + * Create an instance of the model that loads the model and encodes an image + */ + public EfficientViTSAML2(EfficientViTSamEnvManager manager) { + this.isHeavy = false; + this.fullName = "EfficientViT-SAM smallest version (L2)"; + this.githubLink = "https://github.com/mit-han-lab/efficientvit"; + this.githubName = "mit-han-lab/efficientvit"; + this.paperName = "EfficientViT-SAM: Accelerated Segment Anything Model Without Performance Loss"; + this.paperLink = "https://arxiv.org/pdf/2402.05008.pdf"; + this.speedRank = 1; + this.performanceRank = 5; + this.size = 245.7; + if (!manager.getModelType().equals(ID)) + throw new IllegalArgumentException("The model type should be: " + ID + " vs manager model type: " + manager.getModelType()); + this.manager = manager; } @Override diff --git a/src/main/java/ai/nets/samj/communication/model/EfficientViTSAMXL0.java b/src/main/java/ai/nets/samj/communication/model/EfficientViTSAMXL0.java index ac7863b..848d8fb 100644 --- a/src/main/java/ai/nets/samj/communication/model/EfficientViTSAMXL0.java +++ b/src/main/java/ai/nets/samj/communication/model/EfficientViTSAMXL0.java @@ -48,6 +48,8 @@ public class EfficientViTSAMXL0 extends SAMModel { * Axes order required for the input image by the model */ public static final String INPUT_IMAGE_AXES = "xyc"; + + private static final String ID = "xl0"; /** * Create an instance of the model that loads the model and encodes an image @@ -62,7 +64,25 @@ public EfficientViTSAMXL0() { this.speedRank = 3; this.performanceRank = 3; this.size = 468.2; - this.manager = EfficientViTSamEnvManager.create(EfficientViTSamEnvManager.DEFAULT_DIR, "xl0"); + this.manager = EfficientViTSamEnvManager.create(EfficientViTSamEnvManager.DEFAULT_DIR, ID); + } + + /** + * Create an instance of the model that loads the model and encodes an image + */ + public EfficientViTSAMXL0(EfficientViTSamEnvManager manager) { + this.isHeavy = false; + this.fullName = "EfficientViT-SAM smallest version (XL0)"; + this.githubLink = "https://github.com/mit-han-lab/efficientvit"; + this.githubName = "mit-han-lab/efficientvit"; + this.paperName = "EfficientViT-SAM: Accelerated Segment Anything Model Without Performance Loss"; + this.paperLink = "https://arxiv.org/pdf/2402.05008.pdf"; + this.speedRank = 3; + this.performanceRank = 3; + this.size = 468.2; + if (!manager.getModelType().equals(ID)) + throw new IllegalArgumentException("The model type should be: " + ID + " vs manager model type: " + manager.getModelType()); + this.manager = manager; } @Override diff --git a/src/main/java/ai/nets/samj/communication/model/EfficientViTSAMXL1.java b/src/main/java/ai/nets/samj/communication/model/EfficientViTSAMXL1.java index 7a293f2..ed43209 100644 --- a/src/main/java/ai/nets/samj/communication/model/EfficientViTSAMXL1.java +++ b/src/main/java/ai/nets/samj/communication/model/EfficientViTSAMXL1.java @@ -49,6 +49,8 @@ public class EfficientViTSAMXL1 extends SAMModel { * Axes order required for the input image by the model */ public static final String INPUT_IMAGE_AXES = "xyc"; + + private static final String ID = "xl1"; /** @@ -66,6 +68,24 @@ public EfficientViTSAMXL1() { this.size = 814; this.manager = EfficientViTSamEnvManager.create(EfficientViTSamEnvManager.DEFAULT_DIR, "xl1"); } + + /** + * Create an instance of the model that loads the model and encodes an image + */ + public EfficientViTSAMXL1(EfficientViTSamEnvManager manager) { + this.isHeavy = false; + this.fullName = "EfficientViT-SAM smallest version (XL1)"; + this.githubLink = "https://github.com/mit-han-lab/efficientvit"; + this.githubName = "mit-han-lab/efficientvit"; + this.paperName = "EfficientViT-SAM: Accelerated Segment Anything Model Without Performance Loss"; + this.paperLink = "https://arxiv.org/pdf/2402.05008.pdf"; + this.speedRank = 3; + this.performanceRank = 3; + this.size = 814; + if (!manager.getModelType().equals(ID)) + throw new IllegalArgumentException("The model type should be: " + ID + " vs manager model type: " + manager.getModelType()); + this.manager = manager; + } @Override /** diff --git a/src/main/java/ai/nets/samj/communication/model/SAM2Large.java b/src/main/java/ai/nets/samj/communication/model/SAM2Large.java index ac28c68..43a8211 100644 --- a/src/main/java/ai/nets/samj/communication/model/SAM2Large.java +++ b/src/main/java/ai/nets/samj/communication/model/SAM2Large.java @@ -69,6 +69,26 @@ public SAM2Large() { this.size = Math.round(10 * Sam2EnvManager.SAM2_BYTE_SIZES_MAP.get(ID) / ((double) ( 1024 * 1024))) / 10.0; this.manager = Sam2EnvManager.create(Sam2EnvManager.DEFAULT_DIR, ID); } + + + /** + * Create an instance of the model that loads the model and encodes an image + */ + public SAM2Large(Sam2EnvManager manager) { + 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 = "facebookresearch/segment-anything-2"; + this.paperName = "SAM 2: Segment Anything in Images and Videos"; + this.speedRank = 4; + this.performanceRank = 1; + //this.size = Math.round(10 * Sam2EnvManager.SAM2_1_BYTE_SIZES_MAP.get(ID) / ((double) ( 1024 * 1024))) / 10.0; + this.size = Math.round(10 * Sam2EnvManager.SAM2_BYTE_SIZES_MAP.get(ID) / ((double) ( 1024 * 1024))) / 10.0; + if (!manager.getModelType().equals(ID)) + throw new IllegalArgumentException("The model type should be: " + ID + " vs manager model type: " + manager.getModelType()); + this.manager = manager; + } @Override /** 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 c921ce9..587effb 100644 --- a/src/main/java/ai/nets/samj/communication/model/SAM2Small.java +++ b/src/main/java/ai/nets/samj/communication/model/SAM2Small.java @@ -50,7 +50,7 @@ public class SAM2Small extends SAMModel { public static final String INPUT_IMAGE_AXES = "xyc"; private static String ID = "small"; - + /** * Create an instance of the model that loads the model and encodes an image @@ -68,6 +68,25 @@ public SAM2Small() { this.size = Math.round(10 * Sam2EnvManager.SAM2_BYTE_SIZES_MAP.get(ID) / ((double) ( 1024 * 1024))) / 10.0; this.manager = Sam2EnvManager.create(Sam2EnvManager.DEFAULT_DIR, ID); } + + /** + * Create an instance of the model that loads the model and encodes an image + */ + public SAM2Small(Sam2EnvManager manager) { + 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 = "facebookresearch/segment-anything-2"; + this.paperName = "SAM 2: Segment Anything in Images and Videos"; + this.speedRank = 3; + this.performanceRank = 3; + //this.size = Math.round(10 * Sam2EnvManager.SAM2_1_BYTE_SIZES_MAP.get(ID) / ((double) ( 1024 * 1024))) / 10.0; + this.size = Math.round(10 * Sam2EnvManager.SAM2_BYTE_SIZES_MAP.get(ID) / ((double) ( 1024 * 1024))) / 10.0; + if (!manager.getModelType().equals(ID)) + throw new IllegalArgumentException("The model type should be: " + ID + " vs manager model type: " + manager.getModelType()); + this.manager = manager; + } @Override /** 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 aca7de5..92206e2 100644 --- a/src/main/java/ai/nets/samj/communication/model/SAM2Tiny.java +++ b/src/main/java/ai/nets/samj/communication/model/SAM2Tiny.java @@ -68,6 +68,26 @@ public SAM2Tiny() { this.size = Math.round(10 * Sam2EnvManager.SAM2_BYTE_SIZES_MAP.get(ID) / ((double) ( 1024 * 1024))) / 10.0; this.manager = Sam2EnvManager.create(Sam2EnvManager.DEFAULT_DIR, ID); } + + + /** + * Create an instance of the model that loads the model and encodes an image + */ + public SAM2Tiny(Sam2EnvManager manager) { + this.isHeavy = false; + this.fullName = "SAM-2: Segment Anything Model 2 (Tiny)"; + 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 = "facebookresearch/segment-anything-2"; + this.paperName = "SAM 2: Segment Anything in Images and Videos"; + this.speedRank = 2; + this.performanceRank = 4; + //this.size = Math.round(10 * Sam2EnvManager.SAM2_1_BYTE_SIZES_MAP.get(ID) / ((double) ( 1024 * 1024))) / 10.0; + this.size = Math.round(10 * Sam2EnvManager.SAM2_BYTE_SIZES_MAP.get(ID) / ((double) ( 1024 * 1024))) / 10.0; + if (!manager.getModelType().equals(ID)) + throw new IllegalArgumentException("The model type should be: " + ID + " vs manager model type: " + manager.getModelType()); + this.manager = manager; + } @Override /**