You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+46-21Lines changed: 46 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -168,11 +168,11 @@ Or you can download the [Spotiflow_detection_template.groovy](src/main/resources
168
168
169
169
> [!IMPORTANT]
170
170
> Lines starting with `//` are commented out and are not used. To enable those parameters, delete the `//`. To disable a parameter, add `//` at the start of the line.
171
-
> Some exmaples as provided in the [announcement forum post](https://forum.image.sc/t/qupath-extension-spotiflow-is-now-available/115646)
172
171
173
172
### Getting all available arguments
174
173
175
174
All builder options that are implemented are documented [in the Javadoc](https://biop.github.io/qupath-extension-spotiflow/qupath/ext/biop/spotiflow/SpotiflowBuilder.html).
175
+
Examples are provided in the [announcement forum post](https://forum.image.sc/t/qupath-extension-spotiflow-is-now-available/115646).
176
176
You can pass additional options to `spotiflow` by adding `.addParameter()` before the `.build()` line.
177
177
178
178
To get the available additional arguments, call the help from the `spotiflow` object using `spotiflow.helpPredict()`
A QuPath project with rectangles of class "Training" and "Validation" inside which the ground truth objects have been painted as annotations with no class.
228
-

229
228
230
229
> [!IMPORTANT]
231
-
> Training requires _dense_ annotations. This means you cannot just annotate a few objects per Training and Valudation rectanble. You must annotate **ALL relevant objects** within each of those regions!
230
+
> Training requires _dense_ annotations. This means you cannot just annotate a few objects per Training and Validation rectangle. You must annotate **ALL relevant objects** within each of those regions!
232
231
233
232
We typically create a standalone QuPath project for training only. This project will contain the training images along with the ground truth annotations drawn in QuPath.
234
233
Here are some reasons we do it this way:
@@ -240,9 +239,9 @@ Here are some reasons we do it this way:
240
239
241
240
1. In your QuPath project create at least **2** rectangle annotations.
242
241
2. In the Annotations tab, add new classes name "Training" and "Validation" and assign your rectangles to each of them. You do not need an equal number of Training and Validation rectangles.
243
-
3. Lock the rectangles (right click > Annotations > Lock).
244
-
4. Draw your ground truth annotations within all of the rectangles. You can also select each rectangle and run the `Cellpose detection script template` with the `.createAnnotations()` line
245
-
not commented out in the builder (see *Prediction* instructions above) to use a pre-trained cellpose model as a start, but make sure you manually correct it to get proper ground truth!
242
+
3. Lock the rectangles (`right click > Annotations > Lock`).
243
+
4. Draw your ground truth annotations within all of the rectangles. <!--You can also select each rectangle and run the `Spotiflow detection script template` with the `.createAnnotations()` line
244
+
not commented out in the builder (see *Prediction* instructions above) to use a pre-trained cellpose model as a start, but make sure you manually correct it to get proper ground truth!-->
246
245
247
246
> [!IMPORTANT]
248
247
> Any ground truth annotations must have **no classes** assigned.
@@ -252,24 +251,29 @@ Here are some reasons we do it this way:
252
251
> [!WARNING]
253
252
> All images with Training or Validation annotations in the project will be used for the training.
254
253
255
-
Once you have your labeled Training and Validation rectangles with ground truth annotations, make sure you save your project! Then you can run the Cellpose training template script in
256
-
`Extensions > Cellpose > Cellpose training script template`
254
+
Once you have your labeled Training and Validation rectangles with ground truth annotations, make sure you save your project! Then you can run the Spotiflow training template script in
255
+
`Extensions > Spotiflow > Spotiflow training script template`
257
256
258
-
Or you can download [Cellpose_training_template.groovy](src/main/resources/scripts/Cellpose_training_template.groovy) from this repo and run it from the script editor.
257
+
Or you can download [Spotiflow_training_template.groovy](src/main/resources/scripts/Spotiflow_training_script_template.groovy) from this repo and run it from the script editor.
259
258
259
+
> [!IMPORTANT]
260
+
> Lines starting with `//` are commented out and are not used. To enable those parameters, delete the `//`. To disable a parameter, add `//` at the start of the line.
261
+
262
+
<!--
260
263
> [!NOTE]
261
264
> In the line `def cellpose = Cellpose2D.builder("cyto")` you can choose to fine-tune a pre-trained model (e.g. cyto), train from scratch (enter "None"),
262
265
> or start with a custom model (see below). Please see the *Prediction* instructions above for information regarding the other builder parameters.
266
+
-->
263
267
264
-
The first thing the script will do is create a sub-folder in your project called `cellpose-training` containing sub-folders `test` and `train`, followed by exporting the image(s)
265
-
that will be processed by `cellpose`. The `train` folder will contain images of your training rectangles and your annotations converted to masks. The `test` folder will contain the
266
-
Validation data, which is also used by the `QC` script. If your Validation is not what you expect, you can check that the exported image(s) represent what you intended for `cellpose` to train on.
268
+
The first thing the script will do is create a sub-folder in your project called `spotiflow-training` containing sub-folders `val` and `train`, followed by exporting the image(s)
269
+
that will be processed by `spotiflow`. The `train` folder will contain images of your training rectangles and your annotations converted to masks. The `val` folder will contain the
270
+
Validation data, which is also used by the `QC` script. If your Validation is not what you expect, you can check that the exported image(s) represent what you intended for `spotiflow` to train on.
267
271
268
272
Once the script successfully completes training, you will have a `models` sub-folder within your Project folder, which will contain your custom model, as well as a `QC` sub-folder with the output
269
273
of the QC script.
270
274
271
275
Once you are happy with your training script, you should save the edited copy to your Project (or another scripts folder) for re-use!
272
-
276
+
<!--
273
277
### Training a custom model
274
278
To train using your custom model, you need to provide the path to the model to the `Cellpose2D.builder`. Just replace the name of the pre-trained model (e.g. `cyto`)
In case that this might be of use to you, please [open an issue](https://github.com/BIOP/qupath-extension-cellpose/issues).
300
+
-->
301
+
302
+
### Getting all available training options
303
+
304
+
All builder options that are implemented are documented [in the Javadoc](https://biop.github.io/qupath-extension-spotiflow/qupath/ext/biop/spotiflow/SpotiflowBuilder.html).
305
+
Examples are provided in the [announcement forum post](https://forum.image.sc/t/qupath-extension-spotiflow-is-now-available/115646).
306
+
You can pass additional options to `spotiflow` by adding `.addParameter()` before the `.build()` line.
307
+
308
+
To get the available additional arguments, call the help from the `spotiflow` object using `spotiflow.helpTrain()`
309
+
```
310
+
def spotiflow = Spotiflow.builder()...build()
311
+
spotiflow.helpTrain()
312
+
```
313
+
314
+
### Fine-tuning a pre-trained models
315
+
To fine-tune a pre-trained model, provide the name of this model to the `Spotiflow.builder` using `.setModelToFineTune()`
316
+
```
317
+
def pretrainedModel = 'general'
318
+
def spotiflow = Spotiflow.builder()
319
+
.setModelToFineTune(general)
320
+
```
321
+
296
322
297
323
### Training validation
298
-
You can find a [run-cellpose-qc.py](QC/run-cellpose-qc.py) python script in the `QC` folder of this repository. This is
299
-
an adaptation of the Quality Control part of a [ZeroCostDL4Mic Notebook that was made for cellpose](https://colab.research.google.com/github/HenriquesLab/ZeroCostDL4Mic/blob/master/Colab_notebooks/Beta%20notebooks/Cellpose_2D_ZeroCostDL4Mic.ipynb).
324
+
You can find a [run-spotiflow-qc.py](QC/run-spotiflow-qc.py) python script in the `QC` folder of this repository.
300
325
301
326
Basically, when you train using this extension:
302
327
1. It will first train your model as expected
303
-
2. It will then run your newly trained cellpose model on your "Validation" images
304
-
3. At the end, it will run the [run-cellpose-qc.py](QC/run-cellpose-qc.py) python script to output validation metrics.
328
+
2. It will then run your newly trained spotiflow model on your "Validation" images
329
+
3. At the end, it will run the [run-spotiflow-qc.py](QC/run-spotiflow-qc.py) python script to output validation metrics.
305
330
4. The validation metrics will be saved into a folder called `QC` in your QuPath Project
306
331
307
332
308
333
### Saving training results for publication purposes
309
334
310
335
In order to be as reproducible and sure of your results as possible, especially when it comes to publishing, these are
311
336
our current guidelines:
312
-
1. Use `saveBuilder()` which saves a JSON file of your CellposeBuilder, which can be reused with `CellposeBuilder(File builderFile)`. That way you will not lose the setting your did
313
-
2. Save the `cellpose-training`, `QC` and `models` folders at the end of your training somewhere. This will contain everything that was made during training.
337
+
1. Use `saveBuilder()` which saves a JSON file of your SpotiflowBuilder, which can be reused with `SpotiflowBuilder(File builderFile)`. That way you will not lose the setting your did
338
+
2. Save the `spotiflow-training`, `QC` and `models` folders at the end of your training somewhere. This will contain everything that was made during training.
314
339
3. Save the training script as well.
315
340
316
341
317
-
-->
342
+
318
343
# Building
319
344
320
345
You can build the QuPath Spotiflow extension from source with
0 commit comments