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/08/30 13:40] twagner [Data preparation] |
pipeline:window:cryolo [2019/09/17 07:43] twagner [Training] |
||
---|---|---|---|
Line 36: | Line 36: | ||
You can find the download and installation instructions here: [[howto: | You can find the download and installation instructions here: [[howto: | ||
- | ===== Picking particles - Using a model trained for your data ===== | + | ===== Tutorials |
+ | Depending what you want to do, you can follow one of these self-contained Tutorials: | ||
- | ==== Data preparation ==== | + | - I would like to train a model from scratch for picking my particles |
- | If you followed the installation instructions, | + | - I would like to train a model from scratch for picking filaments. |
+ | - I would like to refine a general model for my particles. | ||
- | < | + | 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. |
- | source activate cryolo | + | |
- | </ | + | |
- | 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: | ||
- | * 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. | ||
- | We recommend that you start with 10 micrographs, | ||
- | {{: | + | ===== Picking particles - Using a model trained for your data ===== |
- | To create your training data, crYOLO is shipped with a tool called " | + | |
- | Start the box manager with the following command: | ||
- | < | ||
- | cryolo_boxmanager.py | ||
- | </ | ||
- | Now press //File -> Open image folder// and the select the '' | + | ==== Data preparation ==== |
+ | {{page>pipeline:window: | ||
- | * LEFT MOUSE BUTTON: Place a box | + | ==== Start crYOLO ==== |
- | * HOLD LEFT MOUSE BUTTON: Move a box | + | {{page> |
- | * 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. | + | ==== Configuration ==== |
+ | {{page> | ||
+ | ==== Training ==== | ||
- | If you finished picking from your micrographs, | + | Now you are ready to train the model. In case you have multiple GPUs, you should first select |
- | Create a new directory called '' | + | |
- | + | ||
- | Now create a third folder with the name '' | + | |
- | + | ||
- | ==== Configuration ==== | + | |
- | You now have to create a config file your picking project. To do this type: | + | |
< | < | ||
- | touch config.json | + | nvidia-smi |
</ | </ | ||
+ | For this tutorial, we assume that you have either a single GPU or want to use GPU 0. In the GUI you have to fille the mandatory fields: | ||
+ | {{ : | ||
- | To use the [[: | + | The default number of warmup epochs is fine as long you don't want to refine an existing model. During |
- | <code json config.json> | + | |
- | { | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | " | + | <note> |
- | " | + | Before you start the training, you might want to change |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | + | ||
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | }, | + | |
- | + | ||
- | " | + | |
- | " | + | |
- | " | + | |
- | + | ||
- | " | + | |
- | } | + | |
- | } | + | |
- | </code> | + | |
- | // | + | |
- | + | ||
- | Please set the value in the //" | + | |
< | < | ||
- | " | + | nvidia-smi |
</ | </ | ||
- | crYOLO | + | |
+ | In //" | ||
+ | </ | ||
<note tip> | <note tip> | ||
- | **Alternative: | + | When you start the training, it will stop when the " |
- | + | ||
- | Since crYOLO 1.4 you can also use neural network denoising with [[: | + | |
- | + | ||
- | To use JANNI' | + | |
- | + | ||
- | < | + | |
- | " | + | |
- | </code> | + | |
- | + | ||
- | I recommend | + | |
</ | </ | ||
- | Please note the wiki entry about the [[: | + | Now press the Start button to start the training. The final model will be written to disk as specified in // |
+ | <hidden **Train crYOLO using the command line**> | ||
+ | Navigate to the folder with '' | ||
+ | **Train your network with 5 warmup epochs in GPU 0:** | ||
- | ==== 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: | ||
< | < | ||
- | nvidia-smi | + | cryolo_train.py |
</ | </ | ||
- | For this tutorial, we assume that you have either a single GPU or want to use GPU 0. Therefore we add '-g 0' after each command below. However, if you have multiple (e.g GPU 0 and GPU 1) you could also use both by adding '-g 0 1' after each command. | ||
- | Navigate to the folder with '' | + | The final model file will be written to disk. |
- | **Train your network with 3 warmup epochs:** | ||
- | < | ||
- | cryolo_train.py -c config.json -w 3 -g 0 | ||
- | </ | ||
- | |||
- | The final model will be called '' | ||
- | |||
- | The training stops when the " | ||
< | < | ||
Line 172: | Line 103: | ||
to the training command. | to the training command. | ||
+ | </ | ||
==== Picking ==== | ==== Picking ==== | ||
- | You can now use the model weights saved in '' | + | {{page>pipeline: |
- | < | + | |
- | 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 '' | ||
- | |||
- | 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: | ||
- | < | ||
- | 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 ==== | ||
- | + | {{page>pipeline: | |
- | To visualize your results you can use the box manager: | + | |
- | < | + | |
- | cryolo_boxmanager.py | + | |
- | </ | + | |
- | Now press //File -> Open image// folder and the select the '' | + | |
- | + | ||
- | Since version 1.3.0 crYOLO writes cbox files in a separate '' | + | |
- | + | ||
- | [{{ :pipeline: | + | |
- | + | ||
- | <note warning> | + | |
- | Right now, **this filtering does not yet work for filaments**. | + | |
- | </ | + | |
- | + | ||
- | + | ||
===== Picking particles - Without training using a general model ===== | ===== 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: [[: | 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: [[: | ||
Our general models can be found and downloaded here: [[howto: | Our general models can be found and downloaded here: [[howto: | ||
+ | |||
+ | ==== Start crYOLO ==== | ||
+ | {{page> | ||
+ | |||
==== Configuration==== | ==== Configuration==== | ||
The next step is to create a configuration file. Type: | The next step is to create a configuration file. Type: | ||
Line 273: | Line 183: | ||
==== Picking ==== | ==== Picking ==== | ||
- | Just follow the description given [[pipeline: | + | {{page>pipeline: |
- | + | ||
- | As for a direct trained model, you might want to play around with the confidence threshold, either by using the '' | + | |
+ | ==== Visualize the results ==== | ||
+ | {{page> | ||
===== Picking particles - Using the general model refined for your data ===== | ===== Picking particles - Using the general model refined for your data ===== | ||
Line 288: | Line 197: | ||
Why should I // | 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, | + | - 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 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. | - 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. | ||
Line 294: | Line 203: | ||
However, the fine tune mode is still somewhat experimental and we will update this section if see more advantages or disadvantages. | However, the fine tune mode is still somewhat experimental and we will update this section if see more advantages or disadvantages. | ||
+ | ==== Data preparation ==== | ||
+ | {{page> | ||
+ | |||
+ | ==== Start crYOLO ==== | ||
+ | |||
+ | {{page> | ||
==== Configuration ==== | ==== Configuration ==== | ||
Line 309: | Line 224: | ||
==== Training ==== | ==== Training ==== | ||
- | In comparision | + | In comparison |
< | < | ||
- | cryolo_train.py -c config.json -w 0 -g 0 --fine_tune | + | 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 ==== | + | <note tip> |
+ | **Training on CPU** | ||
The fine tune mode is especially useful if you want to [[downloads: | The fine tune mode is especially useful if you want to [[downloads: | ||
+ | </ | ||
+ | ==== Picking ==== | ||
+ | {{page> | ||
+ | |||
+ | |||
===== 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 333: | Line 252: | ||
==== Data preparation ==== | ==== Data preparation ==== | ||
- | {{ : | + | {{ : |
- | After this is done, you have to prepare | + | The first step is to create the training data for your model. Right now, you have to use the e2helixboxer.py |
- | Right now, you have to use the e2helixboxer.py | + | |
< | < | ||
e2helixboxer.py --gui my_images/ | e2helixboxer.py --gui my_images/ | ||
Line 342: | Line 260: | ||
After tracing your training data in e2helixboxer, | After tracing your training data in e2helixboxer, | ||
- | |||
==== Configuration ==== | ==== Configuration ==== | ||
- | You can configure it the same way as for a " | + | {{page> |
- | + | ||
- | <code json config.json> | + | |
- | { | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | | + | |
- | + | ||
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | + | ||
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | | + | |
- | + | ||
- | " | + | |
- | " | + | |
- | " | + | |
- | + | ||
- | " | + | |
- | } | + | |
- | } | + | |
- | </ | + | |
- | + | ||
- | // | + | |
- | + | ||
- | Just adapt the anchors accordingly to your box size. | + | |
==== Training ==== | ==== Training ==== | ||
Line 416: | Line 289: | ||
==== Visualize the results ==== | ==== Visualize the results ==== | ||
- | You can use the boxmanager as described [[pipeline: | + | {{page>pipeline: |
===== Evaluate your results ===== | ===== Evaluate your results ===== | ||
Line 457: | Line 330: | ||
* // | * // | ||
* // | * // | ||
+ | * // | ||
+ | * //%%-%%lft NUM_LAYER_FINETUNE//: | ||
- | During **picking** (// | + | During **picking** (// |
* //-t CONFIDENCE_THRESHOLD//: | * //-t CONFIDENCE_THRESHOLD//: | ||
* //-d DISTANCE_IN_PIXEL//: | * //-d DISTANCE_IN_PIXEL//: | ||
Line 464: | Line 339: | ||
* // | * // | ||
* // | * // | ||
- | * // | + | * // |
- | * //-sr SEARCH_RANGE_FACTOR//: | + | * // |
+ | * //-sr SEARCH_RANGE_FACTOR//: | ||
+ | |||
===== Help ===== | ===== Help ===== |