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/09/17 13:40]
twagner [Advanced parameters]
pipeline:window:cryolo [2019/09/17 14:14]
twagner [Tutorials]
Line 41: Line 41:
 Depending what you want to do, you can follow one of these self-contained Tutorials: Depending what you want to do, you can follow one of these self-contained Tutorials:
  
-  - I would like to train a model from scratch for picking my particles +  - [[pipeline:window:cryolo:picking_general|I would like to pick particles without training using a general model]] 
-  - I would like to train a model from scratch for picking filaments. +  - [[pipeline:window:cryolo:picking_scratch|I would like to train a model from scratch for picking my particles]] 
-  - I would like to refine a general model for my particles.+  - [[pipeline:window:cryolo:picking_filaments|I would like to train a model from scratch for picking filaments]] 
 +  - [[pipeline:window:cryolo:picking_general_refine|I would like to refine a general model for my particle]]
  
-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 and less training data. +The **first, second and third tutorial** are the most common use cases and well tested. The **fourth tutorial** is still experimental but might give you better results in less time and less training data. 
  
  
  
-===== Picking particles - Using a model trained for your data ===== 
-This tutorial explains you how to train a model specific for you dataset. 
- 
-If you followed the installation instructions, you now have to activate the cryolo virtual environment with 
- 
-<code> 
-source activate cryolo 
-</code> 
-==== Data preparation ==== 
-{{page>pipeline:window:cryolo:data_preparation}} 
- 
-==== Start crYOLO ==== 
-{{page>pipeline:window:cryolo:start_cryolo}} 
- 
-==== Configuration ==== 
-{{page>pipeline:window:cryolo:configuration}} 
- 
-<html> 
-<div style="background-color: #cfc ; padding: 10px; border: 1px solid green;">  
-<b>You can now press the Start button to create you configuration file.</b> 
-</div> 
-</html> 
- 
- 
-{{page>pipeline:window:cryolo:configuration_cmdl_normal}} 
- 
-==== Training ==== 
- 
-{{page>pipeline:window:cryolo:training}} 
-==== Picking ==== 
-{{page>pipeline:window:cryolo:picking}} 
- 
- 
-==== Visualize the results ==== 
-{{page>pipeline:window:cryolo:visualize}} 
- 
-==== Evaluate your results ==== 
-{{page>pipeline:window:cryolo:evaluate_results}} 
-===== Picking particles - Without training using a general model ===== 
-Here you can find how to apply the general models we trained for you. If you would like to train your own general model, please see our extra wiki page: [[:cryolo_train_general_model|How to train your own general model]] 
- 
-Our general models can be found and downloaded here: [[howto:download_latest_cryolo|Download and Installation]].  
- 
-If you followed the installation instructions, you now have to activate the cryolo virtual environment with 
- 
-<code> 
-source activate cryolo 
-</code> 
-==== Start crYOLO ==== 
-{{page>pipeline:window:cryolo:start_cryolo}} 
- 
-==== Configuration==== 
-In the GUI choose the //config// action. Fill in your target box size and leave the //train_image_folder// and //train_annot_folder// fields empty. 
- 
-{{ :pipeline:window:cryolo_filter_options.png?300|}}  
- 
-[[:downloads:cryolo_1#general_phosaurusnet_models|There are three general models available]]. It is important that you choose the same filtering options in //"Model/denoising options"// tab as we did during training the general models: 
- 
-  * General model trained for low-pass filtered images : Select //filter// "LOWPASS" and //low_pass_cutoff// of 0.1 
-  * General model trained for JANNI-denoised images: Select //filter// "JANNI" and the [[:janni_tutorial#download|janni general model]] for //janni_model//. Keep the defaults for //janni_overlap// and //janni_batches// 
-  * General model for negative stain images: Select filter "NONE" 
- 
-<html> 
-<div style="background-color: #cfc ; padding: 10px; border: 1px solid green;">  
-<b>Press the Start button to write the configuration file to disk.  </b> 
-</div> 
-</html> 
- 
- 
- 
-<hidden **Create the configuration file using the command line**> 
-In the following I assume that you target box size is 220. Please adapt if necessary. 
- 
-For the general **[[:cryolo_nets#network_3_phosaurusnet|Phosaurus network]]** trained for **low-pass filtered cryo images** run: 
-<code> 
-cryoloo.py config config_cryolo_.json 220 --filter LOWPASS --low_pass_cutoff 0.1 
-</code> 
- 
-For the general model trained with **neural-network denoised cryo images** (with [[:janni_tutorial#download|JANNI's general model]]) run: 
-<code> 
-cryoloo.py config config_cryolo_.json 220 --filter JANNI --janni_model /path/to/janni_general_model.h5 
-</code> 
- 
-For the general model for **negative stain data** please run: 
-<code> 
-cryoloo.py config config_cryolo_.json 220 --filter NONE 
-</code> 
-</hidden> 
- 
-==== Picking ==== 
-{{page>pipeline:window:cryolo:picking}} 
- 
-==== Visualize the results ==== 
-{{page>pipeline:window:cryolo:visualize}} 
-===== Picking particles - Using the general model refined for your data ===== 
- 
- 
-Since crYOLO 1.3 you can train a model for your data by //fine-tuning// the general model. 
- 
-What does //fine-tuning// mean? 
- 
-The general model was trained on a lot of particles with a variety of shapes and therefore learned a very good set of generic features. The last layers, however, learn a pretty abstract representation of the particles and it might be that they do not perfectly fit for your particle at hand. Fine-tuning only traines the last two convolutional layers, but keep the others fixed. This adjusts the more abstract representation for your specific problem.  
- 
-Why should I //fine-tune// my model instead of training from scratch? 
-  -  From theory, using fine-tuning should reduce the risk of overfitting ((Overfitting means, that the model works good on the training micrographs, but not on new unseen micrographs. The model just memorized what it saw instead of learning generic features.)) and the amount of training data.  
-  - The training is much faster, as not all layers have to be trained. 
-  - The training will need less GPU memory ((We are testing crYOLO with its default configuration on graphic cards with >= 8 GB memory. Using the fine tune mode, it should also work with GPUs with 4 GB memory)) and therefore is usable with NVIDIA cards with less memory.  
-  
-However, the fine tune mode is still somewhat experimental and we will update this section if see more advantages or disadvantages. 
- 
-If you followed the installation instructions, you now have to activate the cryolo virtual environment with 
- 
-<code> 
-source activate cryolo 
-</code> 
- 
-==== Data preparation ==== 
-{{page>pipeline:window:cryolo:data_preparation}} 
- 
-==== Start crYOLO ==== 
- 
-{{page>pipeline:window:cryolo:start_cryolo}} 
-==== Configuration ==== 
-{{page>pipeline:window:cryolo:configuration}} 
- 
-{{ :pipeline:window:cryolo_pretrained_weights.png?300|}} 
-Furthermore, you have to select the model you want to refine. Download the the general model you want to refine specify in the field pretrained_weights in the //"Training options"// tab. 
- 
-<html> 
-<div style="background-color: #cfc ; padding: 10px; border: 1px solid green;">  
-<b>You can now press the Start button to create configuration file.  </b> 
-</div> 
-</html> 
- 
-<hidden **Create the configuration file using the command line:**> 
- 
-I assume your box files for training are in the folder ''train_annotation'' and the corresponding images in ''train_image''. I furthermore assume that your box size in your box files is 160 and the model you want to refine is ''gmodel_phosnet_20190516.h5''. To create the config config_cryolo.json simply run: 
- 
-<code> 
-cryoloo.py config config_cryolo.json 160 --train_image_folder train_image --train_annot_folder train_annot --pretrained_weights gmodel_phosnet_20190516.h5 
-</code> 
- 
-To get a full description of all available options type: 
-<code> 
-cryoloo.py config -h 
-</code> 
- 
-If you want to specify seperate validation folders you can use the %%--%%valid_image_folder and %%--%%valid_annot_folder options: 
- 
-<code> 
-cryoloo.py config config_cryolo.json 160 --train_image_folder train_image --train_annot_folder train_annot --pretrained_weights gmodel_phosnet_20190516.h5 --valid_image_folder valid_img --valid_annot_folder valid_annot  
-</code> 
- 
-</hidden> 
- 
-==== Training ==== 
- 
-Now you are ready to train the model. In case you have multiple GPUs, you should first select a free GPU. The following command will show the status of all GPUs: 
- 
-<code> 
-nvidia-smi 
-</code> 
- 
-For this tutorial, we assume that you have either a single GPU or want to use GPU 0.  
- 
-In the GUI choose the action //train//. In the //"Required arguments"// tab select the configuration file we created in the previous step and set the number of warmup periods to zero. 
-{{ :pipeline:window:cryolo_refine.png?600 |}} 
- 
-In the //"Optional arguments"// tab please check the fine_tune box. 
-{{ :pipeline:window:cryolo_refine_02.png?300 |}} 
-<note important> 
-The number of layers to fine tune (specified by layers_fine_tune in the //"Optional arguments"// tab) is still experimental. The default value of 2 worked for us but you might need more layers.. 
-</note> 
- 
- 
-<note tip> 
- 
-**Training on CPU**  
- 
-The fine tune mode is especially useful if you want to [[downloads:cryolo_1#run_it_on_the_cpu|train crYOLO on the CPU]]. On my local machine it reduced the time for training cryolo on 14 micrographs from 12-15 hours to 4-5 hours. 
-</note> 
- 
-<hidden **Run training with the command line**> 
-In comparison to the training from scratch, you can skip the warm up training ( -w 0 ). Moreover you have to add the //%%--%%fine_tune// flag to tell crYOLO that it should do fine tuning. You can also tell crYOLO how many layers it should fine tune (default is two layers with -lft 2 ): 
- 
-<code> 
-cryolo_train.py -c config.json -w 0 -g 0 --fine_tune -lft 2 
-</code> 
-</hidden> 
- 
-==== Picking ==== 
-{{page>pipeline:window:cryolo:picking}} 
- 
-==== Visualize the results ==== 
-{{page>pipeline:window:cryolo:visualize}} 
- 
-==== Evaluate your results ==== 
-{{page>pipeline:window:cryolo:evaluate_results}} 
-===== Picking filaments - Using a model trained for your data ===== 
-Since version 1.1.0 crYOLO supports picking filaments. 
- 
-Filament mode on Actin: 
- 
-{{:pipeline:window:action_tracing_2.png?300|}}  {{:pipeline:window:action_traceing_1.png?300|}} 
- 
-Filament mode on MAVS (EMPIAR-10031) : 
- 
-{{:pipeline:window:filament_tracing_02.png?300|}}  {{:pipeline:window:filament_tracing_03.png?300|}} 
- 
-If you followed the installation instructions, you now have to activate the cryolo virtual environment with 
- 
-<code> 
-source activate cryolo 
-</code> 
- 
- 
-==== Data preparation ==== 
-{{ :pipeline:window:settings_e2helixboxer.png?300|}}  
- 
-The first step is to create the training data for your model. Right now, you have to use the e2helixboxer.py for this: 
-<code> 
-e2helixboxer.py --gui my_images/*.mrc 
-</code> 
- 
-After tracing your training data in e2helixboxer, export them using //File -> Save//. Make sure that you export particle coordinates as this the only format supported right now (see screenshot). In the following example, it is expected that you exported into a folder called "train_annotation". 
- 
-For projects with roughly 20 filaments per image we successfully trained on 40 images (=> 800 filaments).  
- 
-==== Start crYOLO ==== 
-{{page>pipeline:window:cryolo:start_cryolo}} 
- 
- 
-==== Configuration ==== 
-{{page>pipeline:window:cryolo:configuration}} 
- 
- 
-<html> 
-<div style="background-color: #cfc ; padding: 10px; border: 1px solid green;">  
-<b>You can now press the Start button to create you configuration file. </b> 
-</div> 
-</html> 
- 
- 
-{{page>pipeline:window:cryolo:configuration_cmdl_normal}} 
-==== Training ==== 
- 
-{{page>pipeline:window:cryolo:training}} 
-==== Picking ==== 
-Select the action prediction and fill all arguments in the “Required arguments” tab:  
-{{ :pipeline:window:cryolo:cryolo_prediction.png?600 |}} 
- 
-Now select the "Filament options" tab and check "Activate filament mode", specifiy the filament width (e.g. 100) and define the box distance (e.g. 20 for 90% overlap when using a box size if 200): 
- 
-{{ :pipeline:window:cryolo_filament.png?700 |}} 
- 
-Press the start button to start the picking. The directory ''output_boxes'' will be created and all results are saved there. The format is the eman2 helix format with particle coordinates.  
- 
-You can find a detailed description [[:cryolo_filament_import_relion|how to import crYOLO filament coordinates into Relion here]]. 
- 
-<hidden **Run prediction in commmand line**> 
-Let's assume you want to pick a filament with a width of 100 pixels (-fw 100). The box size is 200x200 and you want a 90% overlap (-bd 20). Moreover, you wish that each filament has at least 6 boxes (-mn 6). The micrographs are in the ''full_data'' directory. Than the picking command would be: 
-<code> 
-cryolo_predict.py -c cryolo_config.json -w cryolo_model.h5 -i full_data --filament -fw 100 -bd 20 -o boxes/ -g 0 -mn 6 
-</code> 
-</hidden> 
- 
- 
- 
-==== Visualize the results ==== 
-{{page>pipeline:window:cryolo:visualize}} 
  
  
pipeline/window/cryolo.txt · Last modified: 2021/02/19 10:00 by twagner