3535import java .util .Map ;
3636
3737import net .imglib2 .appose .ShmImg ;
38+ import net .imglib2 .cellpose .Cellpose3Parameters .Builder ;
3839import net .imglib2 .type .NativeType ;
3940import net .imglib2 .type .numeric .IntegerType ;
4041import net .imglib2 .type .numeric .RealType ;
4142import net .imglib2 .type .numeric .integer .UnsignedByteType ;
4243
4344public class Cellpose4Parameters extends CellposeParameters
4445{
45-
46+ public final Cellpose4BuiltinModels buitInModel ;
47+
4648 public final Integer chan0 ; // as Integer so that it can be null
4749
4850 public final Integer chan1 ;
4951
5052 public final Integer chan2 ;
5153
5254 private Cellpose4Parameters (
55+ final Cellpose4BuiltinModels buitInModel ,
5356 final Integer chan0 ,
5457 final Integer chan1 ,
5558 final Integer chan2 ,
@@ -75,6 +78,7 @@ private Cellpose4Parameters(
7578 cellProbThreshold , useGpu , minSize , anisotropy ,
7679 stitchThreshold , resample , tileOverlap , computeFlows ,
7780 flow3dSmooth , nIter , torchVersion );
81+ this .buitInModel = buitInModel ;
7882 this .chan0 = chan0 ;
7983 this .chan1 = chan1 ;
8084 this .chan2 = chan2 ;
@@ -87,7 +91,10 @@ public < T extends RealType< T > & NativeType< T >, R extends IntegerType< R > &
8791 final ShmImg < R > outputLabels ,
8892 final ShmImg < UnsignedByteType > outputFlows )
8993 {
94+
9095 final Map < String , Object > inputs = super .toApposeMap ( input , axisInfo , outputLabels , outputFlows );
96+ final boolean isBuiltInModel = customModel == null || customModel .equals ( "" );
97+ inputs .put ( "model_name" , isBuiltInModel ? buitInModel .modelName () : null );
9198
9299 final long nChannels = axisInfo .nChannels ( input );
93100 inputs .put ( "n_channels" , nChannels );
@@ -106,6 +113,13 @@ public static Builder builder()
106113 // Builder class for fluent construction
107114 public static class Builder extends CellposeParameters .Builder < Builder >
108115 {
116+ private Cellpose4BuiltinModels model = Cellpose4BuiltinModels .CPSAMV2 ;
117+
118+ public Builder model ( final Cellpose4BuiltinModels model )
119+ {
120+ this .model = model ;
121+ return this ;
122+ }
109123
110124 private Integer chan0 = 0 ; // to have one selected by default
111125
@@ -135,7 +149,7 @@ public Builder chan2( final Integer chan2 )
135149 public Cellpose4Parameters build ()
136150 {
137151 return new Cellpose4Parameters (
138- chan0 , chan1 , chan2 , customModel , diameter , do3D , normalize ,
152+ model , chan0 , chan1 , chan2 , customModel , diameter , do3D , normalize ,
139153 flowThreshold , cellProbThreshold , useGpu , minSize ,
140154 anisotropy , stitchThreshold , resample , tileOverlap ,
141155 computeFlows , flow3dSmooth , nIter , torchVersion );
0 commit comments