Skip to content

Commit

Permalink
add new constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Dec 17, 2024
1 parent b34b583 commit 0d2f510
Show file tree
Hide file tree
Showing 9 changed files with 182 additions and 7 deletions.
18 changes: 17 additions & 1 deletion src/main/java/ai/nets/samj/communication/model/EfficientSAM.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";



Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";


/**
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";


/**
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";


/**
Expand All @@ -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
/**
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/ai/nets/samj/communication/model/SAM2Large.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
/**
Expand Down
21 changes: 20 additions & 1 deletion src/main/java/ai/nets/samj/communication/model/SAM2Small.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
/**
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/ai/nets/samj/communication/model/SAM2Tiny.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
/**
Expand Down

0 comments on commit 0d2f510

Please sign in to comment.