User Tools

Site Tools


pipeline:window:cryolo

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
pipeline:window:cryolo [2019/07/29 16:02]
twagner [Configuration]
pipeline:window:cryolo [2019/09/14 10:14]
twagner [Picking]
Line 36: Line 36:
 You can find the download and installation instructions here: [[howto:download_latest_cryolo|Download and Installation]] You can find the download and installation instructions here: [[howto:download_latest_cryolo|Download and Installation]]
  
-===== Picking particles - Using a model trained for your data =====+===== Tutorials =====
  
 +Depending what you want to do, you can follow one of these Tutorials:
  
-==== Data preparation ==== +  - I would like to train a model from scratch for picking my particles 
-CrYOLO supports MRC, TIF and JPG files. It can work with 32 bit data, 8 bit data and 16 bit data+  - I would like to train a model from scratch for picking filaments
-It will work on original MRC files, but it will probably improve when the data are denoised. Therefore you should low-pass filter them to a reasonable level. Since Version 1.2 crYOLO can automatically do that for youYou just have to add +  I would like to refine general model for my particles.
-<code> +
-"filter":               [0.1,"filtered"+
-</code> +
  
-to the model section in your config file to filter your images down to an absolute frequency of 0.1. The filtered images are saved in folder ''filtered''.+The **first and the second tutorial** are the most common use cases and well tested. The **third tutorial** is still experimental but might give you better results in less time or less training data
  
-crYOLO will automatically check if an image in full_data is available in the ''filtered'' directory. The filtering is done in parallel. If you don't want to use crYOLO's internal filtering, just remove the line and filter them manually. If you remove the line, don't forget to remove the comma at the end of the line above.  
  
-<hidden **Alternative: Using neural-network denoising with JANNI**> 
-<html><br></html> 
-Since crYOLO 1.4 you can also use neural network denoising with [[:janni|JANNI]]. The easiest way is to use the JANNI's general model ([[:janni#janni_general_model|Download here]]) but you can also [[:janni_tutorial#training_a_model_for_your_data|train JANNI for your data]]. crYOLO directly uses an interface to JANNI to filter your data, you just have to specify the path to your JANNI model, overlap of the batches (default 24), the batch size (default 3) and a path where the denoised images should be written.  
  
-To use JANNI's denoising you have to use following entry in your config.json:+===== Picking particles - Using a model trained for your data =====
  
-<code> 
-"filter":               ["path/to/janni_model.h5",24,3,"filtered"] 
-</code>  
- 
-I recommend to use denoising with JANNI only together with a GPU as it is rather slow (~ 1-2 seconds per micrograph on the GPU and 10 seconds per micrograph on the CPU) 
- 
-<html><br></html> 
-</hidden>  
-<html><br></html> 
  
 +==== Data preparation ====
 If you followed the installation instructions, you now have to activate the cryolo virtual environment with If you followed the installation instructions, you now have to activate the cryolo virtual environment with
  
Line 77: Line 63:
 One may ask how many micrographs have to be picked? It depends! Typically 10 micrographs are a good start. However, that number may increase / decrease due to several factors: One may ask how many micrographs have to be picked? It depends! Typically 10 micrographs are a good start. However, that number may increase / decrease due to several factors:
   * A very heterogenous background could make it necessary to pick more micrographs.   * A very heterogenous background could make it necessary to pick more micrographs.
 +  * When you refine a general model, you might need to pick less micrographs.
   * If your micrograph is only sparsely decorated, you may need to pick more micrographs.   * If your micrograph is only sparsely decorated, you may need to pick more micrographs.
-We recommend that you start with 10 micrographs, then autopick your data, check the results and finally decide whether to add more micrographs to your training set. 
  
 +We recommend that you start with 10 micrographs, then autopick your data, check the results and finally decide whether to add more micrographs to your training set. If you refine a general model, even 5 micrographs might be enough.
  
 {{:pipeline:window:box_manager.png?direct&400 |}} {{:pipeline:window:box_manager.png?direct&400 |}}
Line 95: Line 82:
   * CONTROL + LEFT MOUSE BUTTON: Remove a box   * CONTROL + LEFT MOUSE BUTTON: Remove a box
  
-You can change the box size in the main window, by changing the number in the text field labeled //Box size://. Press //Set// to apply it to all picked particles. For picking, you should the use minimum sized square which encloses your particle.+You can change the box size in the main window, by changing the number in the text field labeled //Box size://. Press //Set// to apply it to all picked particles. __For picking, you should the use minimum sized square which encloses your particle.__
  
 If you finished picking from your micrographs, you can export your box files with //Files -> Write box files//. If you finished picking from your micrographs, you can export your box files with //Files -> Write box files//.
Line 101: Line 88:
  
 Now create a third folder with the name ''train_image''. Now for each box file, copy the corresponding image from ''full_data'' into ''train_image''((While it is nice to keep the things organized, you don't have to copy your training images in a separate folder. In the configuration file (see below) you can also simply specify the full_data directory as "//train_image_folder//". crYOLO will find the correct images using the box files.)). crYOLO will detect image / box file pairs by search taking the box file an searching for an image filename which contains the box filename. Now create a third folder with the name ''train_image''. Now for each box file, copy the corresponding image from ''full_data'' into ''train_image''((While it is nice to keep the things organized, you don't have to copy your training images in a separate folder. In the configuration file (see below) you can also simply specify the full_data directory as "//train_image_folder//". crYOLO will find the correct images using the box files.)). crYOLO will detect image / box file pairs by search taking the box file an searching for an image filename which contains the box filename.
 +
 +==== Start crYOLO ====
 +{{page>pipeline:window:cryolo:start_cryolo}}
  
 ==== Configuration ==== ==== Configuration ====
-You now have to create a config file your picking project. To do this type:+You now have to create a configuration file your picking project. It contains all important constants and paths and helps you to reproduce your results later on.  
 + 
 +You can either use the commandline to create the configuration file or the GUI. 
 + 
 +**Using the command line:** 
 + 
 +To create an empty file do:
 <code> <code>
 touch config.json touch config.json
Line 149: Line 145:
 //[[:cryolo_config|Click here to get more information about the configuration file]]// //[[:cryolo_config|Click here to get more information about the configuration file]]//
  
-Please set the value in the //"anchors"// field to your desired box size. It should be size of the minimum enclosing square in pixels. Furthermore check if the fields //"train_image_folder"// and //"train_annot_folder"// have the correct values. Typically, 20% of the training data are randomly chosen as validation data. If you want to use specific images as validation data, you can move the images and the corresponding box files to the folders specified in //"valid_image_folder"// and //"valid_annot_folder"//. Make sure that they are removed from the original training folder! With the line below, crYOLO automatically filters your images to an absolute frequency 0.1 and write them into a folder "filtered".+Please set the value in the //"anchors"// field to your desired box size. It should be the same as in your training box files. Furthermore check if the fields //"train_image_folder"// and //"train_annot_folder"// have the correct values. Typically, 20% of the training data are randomly chosen as validation data. If you want to use specific images as validation data, you can move the images and the corresponding box files to the folders specified in //"valid_image_folder"// and //"valid_annot_folder"//. Make sure that they are removed from the original training folder! With the line below, crYOLO automatically filters your images to an absolute frequency 0.1 and write them into a folder "filtered".
 <code> <code>
 "filter":               [0.1,"filtered"]. "filter":               [0.1,"filtered"].
Line 158: Line 154:
 **Alternative: Using neural-network denoising with JANNI** **Alternative: Using neural-network denoising with JANNI**
  
-Since crYOLO 1.4 you can also use neural network denoising with [[:janni|JANNI]]. The easiest way is to use the JANNI's general model ([[:janni#janni_general_model|Download here]]) but you can also [[:janni_tutorial#training_a_model_for_your_data|train JANNI for your data]]. crYOLO directly uses an interface to JANNI to filter your data, you just have to specify the path to your JANNI model, overlap of the batches (default 24), the batch size (default 3) and a path where the denoised images should be written. +Since crYOLO 1.4 you can also use neural network denoising with [[:janni|JANNI]]. The easiest way is to use the JANNI's general model ([[:janni#janni_general_model|Download here]]) but you can also [[:janni_tutorial#training_a_model_for_your_data|train JANNI for your data]]. crYOLO directly uses an interface to JANNI to filter your data, you just have to specify the path to your JANNI model, overlap of the patches (default 24), the batch size (default 3) and a path where the denoised images should be written. 
  
 To use JANNI's denoising you have to use following entry in your config.json: To use JANNI's denoising you have to use following entry in your config.json:
Line 172: Line 168:
 Please note the wiki entry about the [[:cryolo_config|crYOLO configuration file]] if you want to know more details. Please note the wiki entry about the [[:cryolo_config|crYOLO configuration file]] if you want to know more details.
  
 +**Using the GUI:**
  
 ==== Training ==== ==== Training ====
Line 184: Line 180:
 Navigate to the folder with ''config.json'' file, ''train_image'' folder, etc. Navigate to the folder with ''config.json'' file, ''train_image'' folder, etc.
  
-**1. Warm up your network**+**Train your network with 3 warmup epochs:**
  
 <code> <code>
 cryolo_train.py -c config.json -w 3 -g 0 cryolo_train.py -c config.json -w 3 -g 0
-</code> 
- 
-**2. Train your network** 
- 
-<code> 
-cryolo_train.py -c config.json -w 0 -g 0 
 </code> </code>
  
Line 199: Line 189:
  
 The training stops when the "loss" metric on the validation data does not improve 10 times in a row. This is typically enough. In case want to give the training more time to find the best model. You might increase the "not changed in a row" parameter to, for example, 15 by adding the flag //-e 15//: The training stops when the "loss" metric on the validation data does not improve 10 times in a row. This is typically enough. In case want to give the training more time to find the best model. You might increase the "not changed in a row" parameter to, for example, 15 by adding the flag //-e 15//:
 +
 <code> <code>
-cryolo_train.py -c config.json -w -g 0 -e 15+cryolo_train.py -c config.json -w -g 0 -e 15
 </code> </code>
 +
 to the training command. to the training command.
 ==== Picking ==== ==== Picking ====
-You can now use the model weights saved in ''model.h5'' (//if you come to this section from another point of the tutorial, this filename might be different like ''gmodel_phosnet_X_Y.h5''//) to pick all your images in the directory ''full_data''. To do this, run:  +{{page>pipeline:window:cryolo:picking}}
-<code> +
-cryolo_predict.py -c config.json -w model.h5 -i full_data/ -g 0 -o boxfiles/ +
-</code>+
  
-You will find the picked particles in the directory ''boxfiles''. 
- 
-If you want to pick less conservatively or more conservatively you might want to change the selection threshold from the default of 0.3 to a less conservative value like 0.2 or more conservative value like 0.4 using the //-t// parameter: 
-<code> 
-cryolo_predict.py -c config.json -w model.h5 -i full_data/ -g 0 -o boxfiles/ -t 0.2 
-</code> 
-However, it is much easier to select the best threshold after picking using the ''CBOX'' files written by crYOLO as described in the next section 
  
 ==== Visualize the results ==== ==== Visualize the results ====
Line 239: Line 221:
  
 Our general models can be found and downloaded here: [[howto:download_latest_cryolo|Download and Installation]].  Our general models can be found and downloaded here: [[howto:download_latest_cryolo|Download and Installation]]. 
 +
 +==== Start crYOLO ====
 +{{page>pipeline:window:cryolo:start_cryolo}}
 +
 ==== Configuration==== ==== Configuration====
 The next step is to create a configuration file. Type: The next step is to create a configuration file. Type:
Line 424: Line 410:
 In principle, there is not much difference in training crYOLO for filament picking and particle picking. For project with roughly 20 filaments per image we successfully trained on 40 images (=> 800 filaments). However, in our experience the warm-up phase and training need a little bit more time: In principle, there is not much difference in training crYOLO for filament picking and particle picking. For project with roughly 20 filaments per image we successfully trained on 40 images (=> 800 filaments). However, in our experience the warm-up phase and training need a little bit more time:
  
-**1. Warm up your network** +**Train your network with 10 warm up epochs:**
- +
-<code> +
-cryolo_train.py -c config.json -w 10 -g 0 +
-</code> +
- +
-**2. Train your network**+
  
 <code> <code>
-cryolo_train.py -c config.json -w -g 0 -e 10+cryolo_train.py -c config.json -w 10 -g 0 -e 10
 </code> </code>
  
pipeline/window/cryolo.txt · Last modified: 2021/02/19 10:00 by twagner