This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
pipeline:window:cryolo [2019/02/26 08:13] twagner [Configuration] |
pipeline:window:cryolo [2019/04/03 14:54] twagner [Data preparation] |
||
---|---|---|---|
Line 7: | Line 7: | ||
* crYOLO makes picking **smart** -- The network learns the context of particles (e.g. not to pick particles on carbon or within ice contamination ) | * crYOLO makes picking **smart** -- The network learns the context of particles (e.g. not to pick particles on carbon or within ice contamination ) | ||
* crYOLO makes training **easy** -- You might use a general network model and skip training completely. However, if the general model doesn' | * crYOLO makes training **easy** -- You might use a general network model and skip training completely. However, if the general model doesn' | ||
+ | * crYOLO makes training **lenient** -- Don't worry if you miss quite a lot particles during creation of your training set. [[: | ||
In this tutorial we explain our recommended configurations for single particle and filament projects. You can find more information about supported networks and about the config file in the following articles: | In this tutorial we explain our recommended configurations for single particle and filament projects. You can find more information about supported networks and about the config file in the following articles: | ||
* [[: | * [[: | ||
* [[: | * [[: | ||
+ | |||
+ | You can find more technical details in our paper: | ||
+ | |||
+ | [[https:// | ||
+ | ]] | ||
+ | |||
+ | < | ||
+ | <a href=" | ||
+ | </ | ||
===== Installation ===== | ===== Installation ===== | ||
You can find the download and installation instructions here: [[howto: | You can find the download and installation instructions here: [[howto: | ||
- | ===== Picking - Using a model trained for your data ===== | + | ===== Picking |
Line 34: | Line 44: | ||
In the following I will assume that your image data is in the folder '' | In the following I will assume that your image data is in the folder '' | ||
- | The next step is to create training data. To do so, we have to pick single particles manually in several micrographs. Ideally, the micrographs are picked to completion. 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: | + | The next step is to create training data. To do so, we have to pick single particles manually in several micrographs. Ideally, the micrographs are picked to completion. |
+ | 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. | ||
* 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. | ||
Line 59: | Line 70: | ||
Create a new directory called '' | Create a new directory called '' | ||
- | Now create a third folder with the name '' | + | Now create a third folder with the name '' |
==== Configuration ==== | ==== Configuration ==== | ||
Line 108: | Line 119: | ||
// | // | ||
- | Please set the value in the //" | + | Please set the value in the //" |
< | < | ||
" | " | ||
Line 142: | Line 153: | ||
The final model will be called '' | The final model will be called '' | ||
- | The training stops when the " | + | The training stops when the " |
< | < | ||
- | cryolo_train.py -c config.json -w 0 -g 0 -e 10 | + | cryolo_train.py -c config.json -w 0 -g 0 -e 15 |
</ | </ | ||
to the training command. | to the training command. | ||
==== Picking ==== | ==== Picking ==== | ||
- | You can now use the model weights saved in '' | + | You can now use the model weights saved in '' |
< | < | ||
cryolo_predict.py -c config.json -w model.h5 -i full_data/ -g 0 -o boxfiles/ | cryolo_predict.py -c config.json -w model.h5 -i full_data/ -g 0 -o boxfiles/ | ||
</ | </ | ||
- | You will find the picked particles in the directory '' | + | You will find the picked particles in the directory '' |
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: | 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: | ||
Line 159: | Line 170: | ||
cryolo_predict.py -c config.json -w model.h5 -i full_data/ -g 0 -o boxfiles/ -t 0.2 | cryolo_predict.py -c config.json -w model.h5 -i full_data/ -g 0 -o boxfiles/ -t 0.2 | ||
</ | </ | ||
+ | However, it is much easier to select the best threshold after picking using the '' | ||
==== Visualize the results ==== | ==== Visualize the results ==== | ||
Line 166: | Line 178: | ||
cryolo_boxmanager.py | cryolo_boxmanager.py | ||
</ | </ | ||
- | Now press //File -> Open image// folder and the select the '' | + | Now press //File -> Open image// folder and the select the '' |
+ | |||
+ | Since version 1.3.0 crYOLO writes cbox files in a separate '' | ||
+ | |||
+ | [{{ : | ||
+ | Right now, **this filtering does not yet work for filaments**. | ||
- | ===== Picking - Without training using a general model ===== | + | ===== Picking |
- | The general | + | The general |
==== Configuration==== | ==== Configuration==== | ||
The next step is to create a configuration file. Type: | The next step is to create a configuration file. Type: | ||
Line 217: | Line 234: | ||
Just follow the description given [[pipeline: | Just follow the description given [[pipeline: | ||
- | As for a direct trained model, you might want to play around with the -t parameter | + | As for a direct trained model, you might want to play around with the confidence threshold, either by using the '' |
+ | |||
+ | ===== Picking particles - Using the general model refined for your data ===== | ||
+ | |||
+ | |||
+ | Since crYOLO 1.3 you can train a model for your data by // | ||
+ | |||
+ | What does // | ||
+ | |||
+ | 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 // | ||
+ | - From theory, using fine-tuning should reduce the risk of overfitting ((Overfitting means, that the model works good on the training micrographs, | ||
+ | - 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. | ||
+ | |||
+ | ==== Configuration ==== | ||
+ | |||
+ | You can use almost the same configuration as used when [[pipeline: | ||
+ | |||
+ | < | ||
+ | " | ||
+ | [...] | ||
+ | " | ||
+ | [...] | ||
+ | " | ||
+ | [...] | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ==== Training ==== | ||
+ | In comparision to the training from scratch, you can skip the warm up training. Moreover you have to add the // | ||
+ | |||
+ | < | ||
+ | cryolo_train.py -c config.json -w 0 -g 0 --fine_tune | ||
+ | </ | ||
+ | ==== Picking ==== | ||
+ | Picking is identical as with a model trained from scratch, so we will skip it here. Just follow the description given [[pipeline: | ||
+ | |||
+ | ==== Training on CPU ==== | ||
+ | |||
+ | |||
+ | The fine tune mode is especially useful if you want to [[downloads: | ||
===== Picking filaments - Using a model trained for your data ===== | ===== Picking filaments - Using a model trained for your data ===== | ||
Since version 1.1.0 crYOLO supports picking filaments. | Since version 1.1.0 crYOLO supports picking filaments. | ||
Line 234: | Line 295: | ||
After this is done, you have to prepare training data for your model. | After this is done, you have to prepare training data for your model. | ||
- | Right now, you have to use the sxhelixboxer.py to generate the training data: | + | Right now, you have to use the e2helixboxer.py to generate the training data: |
< | < | ||
- | sxhelixboxer.py --gui my_images/ | + | e2helixboxer.py --gui my_images/ |
</ | </ | ||
- | After tracing your training data in sxhelixboxer, 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 " | + | 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 " |
==== Configuration ==== | ==== Configuration ==== | ||
- | You can configure it the same way as for a " | + | You can configure it the same way as for a " |
<code json config.json> | <code json config.json> | ||
{ | { | ||
" | " | ||
- | " | + | " |
- | " | + | " |
- | " | + | " |
" | " | ||
- | " | + | " |
- | " | + | " |
}, | }, | ||
Line 281: | Line 343: | ||
} | } | ||
</ | </ | ||
+ | |||
// | // | ||
Line 352: | Line 415: | ||
===== Advanced parameters ===== | ===== Advanced parameters ===== | ||
- | During **training** (// | + | During **training** (// |
- | * // | + | * //%%--%%warm_restarts//: |
+ | * // | ||
+ | * // | ||
+ | * // | ||
- | During **picking** (// | + | During **picking** (// |
- | * //-t confidence_threshold//: With the -t parameter, you can let the crYOLO pick more conservative (e.g by adding -t 0.4 to the picking command) or less conservative (e.g by adding -t 0.2 to the picking command). The valid parameter range is 0 to 1. | + | * //-t CONFIDENCE_THRESHOLD//: With the -t parameter, you can let the crYOLO pick more conservative (e.g by adding -t 0.4 to the picking command) or less conservative (e.g by adding -t 0.2 to the picking command). The valid parameter range is 0 to 1. |
- | * //-d distance_in_pixel//: With the -d parameter you can filter your picked particles. Boxes with a distance (pixel) less than this value will be removed. | + | * //-d DISTANCE_IN_PIXEL//: With the -d parameter you can filter your picked particles. Boxes with a distance (pixel) less than this value will be removed. |
- | * // | + | * // |
+ | * // | ||
+ | * // | ||
+ | * // | ||
===== Help ===== | ===== Help ===== |