123 : base(handle)
124 {
125
126 string app = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
127 if (microSAM)
128 {
129 if (!File.Exists(app + "/micro-sam-decoder.onnx") || !File.Exists(app + "/micro-sam-encoder.onnx"))
130 {
131 MessageDialog dialog = new MessageDialog(
132 this,
133 DialogFlags.Modal,
134 MessageType.Info,
135 ButtonsType.Ok,
136 "Place Model files \"micro-sam-decoder.onnx\" and \"micro-sam-encoder.onnx\" in the application folder to use SAM Tool.");
137 dialog.Run();
138 return;
139 }
140 }
141 else
142 {
143 if (!File.Exists(app + "/decoder-quant.onnx") || !File.Exists(app + "/encoder-quant.onnx"))
144 {
145 MessageDialog dialog = new MessageDialog(
146 this,
147 DialogFlags.Modal,
148 MessageType.Info,
149 ButtonsType.Ok,
150 "Place Model files \"decoder-quant.onnx\" and \"encoder-quant.onnx\" in the application folder to use SAM Tool.");
151 dialog.Run();
152 return;
153 }
154 }
155 view = App.viewer;
156 _builder = builder;
157 builder.Autoconnect(this);
158 thresholdBar.Adjustment.Lower = 0;
159 if (ImageView.SelectedImage.SelectedBuffer.BitsPerPixel > 8)
160 thresholdBar.Adjustment.Upper = ushort.MaxValue;
161 else
162 thresholdBar.Adjustment.Upper = 255;
163 stabilityBar.Adjustment.Lower = 0;
164 stabilityBar.Adjustment.Upper = 1;
165 stabilityBar.Adjustment.StepIncrement = 0.05;
166 stabilityBar.Value = 0.5;
167 predictionBar.Adjustment.Lower = 0;
168 predictionBar.Adjustment.Upper = 1;
169 predictionBar.Adjustment.StepIncrement = 0.05;
170 predictionBar.Value = 0.5;
171 pointsBar.Adjustment.Lower = 0;
172 pointsBar.Adjustment.Upper = 100;
173 pointsBar.Adjustment.StepIncrement = 1;
174 pointsBar.Value = 4;
175 layersBar.Adjustment.Lower = 0;
176 layersBar.Adjustment.Upper = 4;
177 layersBar.Value = 0;
178 minAreaBar.Value = 0;
179 minAreaBar.Adjustment.Upper = ImageView.SelectedImage.Volume.Width * ImageView.SelectedImage.Volume.Height;
180 minAreaBar.Adjustment.Lower = 0;
181
182 maxAreaBar.Adjustment.Upper = ImageView.SelectedImage.Volume.Width * ImageView.SelectedImage.Volume.Height;
183 maxAreaBar.Adjustment.Lower = 0;
184 maxAreaBar.Value = ImageView.SelectedImage.Volume.Width * ImageView.SelectedImage.Volume.Height;
185 foregroundBut.Active = true;
186 Directory.CreateDirectory("Masks");
187 filechooser =
188 new Gtk.FileChooserDialog("Choose file to open",
189 this,
190 FileChooserAction.Open,
191 "Cancel", ResponseType.Cancel,
192 "OK", ResponseType.Accept);
195 App.ApplyStyles(this);
196 init = true;
197 }