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/09/13 19:24] twagner |
pipeline:window:cryolo [2019/09/15 09:57] twagner [Picking particles - Using the general model refined for your data] |
||
---|---|---|---|
Line 38: | Line 38: | ||
===== Tutorials ===== | ===== Tutorials ===== | ||
- | Depending what you want to do, you can follow one of these Tutorials: | + | Depending what you want to do, you can follow one of these self-contained |
- I would like to train a model from scratch for picking my particles | - I would like to train a model from scratch for picking my particles | ||
Line 44: | Line 44: | ||
- I would like to refine a general model for my particles. | - 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 or less training data. | + | 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. |
Line 52: | Line 52: | ||
==== Data preparation ==== | ==== Data preparation ==== | ||
- | If you followed the installation instructions, | + | {{page>pipeline: |
- | + | ||
- | < | + | |
- | 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, | + | |
- | + | ||
- | {{:pipeline: | + | |
- | 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 '' | + | |
- | + | ||
- | * LEFT MOUSE BUTTON: Place a box | + | |
- | * HOLD LEFT MOUSE BUTTON: Move 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.__ | + | |
- | + | ||
- | If you finished picking from your micrographs, | + | |
- | Create a new directory called '' | + | |
- | + | ||
- | Now create a third folder with the name '' | + | |
==== Start crYOLO ==== | ==== Start crYOLO ==== | ||
- | You can use crYOLO either by command line or by using the GUI. The GUI should be easier for most users. You can start it with: | + | {{page>pipeline:window:cryolo:start_cryolo}} |
- | <code> | + | |
- | cryoloo.py | + | |
- | </ | + | |
- | + | ||
- | SCREENSHOT HERE | + | |
- | + | ||
- | The crYOLO GUI is basically a visualization of the commandline interface. On left side, you find all possible " | + | |
- | * **conifg**: With this action you create the configuration file that you need to run crYOLO. | + | |
- | * **train**: This action let you train crYOLO from scratch or refine an existing model. | + | |
- | * **predict**: If you have your model ready, you can pick the particles on your dataset using this command. | + | |
- | * **evaluation**: This action helps you need to quantify the " | + | |
- | + | ||
- | Each action has several parameters which are organized in tabs. Once you chosen your settings you can press " | + | |
- | + | ||
- | SCREENSHOT HERE | + | |
- | + | ||
- | It will tell you when something went wrong. Pressing " | + | |
==== Configuration ==== | ==== Configuration ==== | ||
- | 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. | + | {{page> |
- | + | ||
- | You can either use the commandline to create the configuration file or the GUI. | + | |
- | + | ||
- | **Using the command line:** | + | |
- | + | ||
- | To create an empty file do: | + | |
- | < | + | |
- | touch config.json | + | |
- | </ | + | |
- | + | ||
- | To use the [[: | + | |
- | <code json config.json> | + | |
- | { | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | | + | |
- | + | ||
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | + | ||
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | " | + | |
- | | + | |
- | + | ||
- | " | + | |
- | " | + | |
- | " | + | |
- | + | ||
- | " | + | |
- | } | + | |
- | } | + | |
- | </ | + | |
- | // | + | |
- | + | ||
- | Please set the value in the //" | + | |
- | < | + | |
- | " | + | |
- | </ | + | |
- | crYOLO will automatically check if an image in full_data is available in the '' | + | |
- | + | ||
- | <note tip> | + | |
- | **Alternative: | + | |
- | + | ||
- | Since crYOLO 1.4 you can also use neural network denoising with [[: | + | |
- | + | ||
- | To use JANNI' | + | |
- | + | ||
- | < | + | |
- | " | + | |
- | </ | + | |
- | + | ||
- | 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) | + | |
- | + | ||
- | </ | + | |
- | + | ||
- | Please note the wiki entry about the [[: | + | |
- | + | ||
- | **Using the GUI:** | + | |
==== Training ==== | ==== Training ==== | ||
Line 211: | Line 85: | ||
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 311: | Line 163: | ||
==== 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 326: | Line 177: | ||
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 332: | Line 183: | ||
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 347: | Line 204: | ||
==== 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 371: | Line 232: | ||
==== 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 380: | Line 240: | ||
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 454: | Line 269: | ||
==== Visualize the results ==== | ==== Visualize the results ==== | ||
- | You can use the boxmanager as described [[pipeline: | + | {{page>pipeline: |
===== Evaluate your results ===== | ===== Evaluate your results ===== | ||
Line 495: | Line 310: | ||
* // | * // | ||
* // | * // | ||
+ | * // | ||
+ | * //%%-%%lft NUM_LAYER_FINETUNE//: | ||
- | During **picking** (// | + | During **picking** (// |
* //-t CONFIDENCE_THRESHOLD//: | * //-t CONFIDENCE_THRESHOLD//: | ||
* //-d DISTANCE_IN_PIXEL//: | * //-d DISTANCE_IN_PIXEL//: | ||
Line 502: | Line 319: | ||
* // | * // | ||
* // | * // | ||
- | * // | + | * // |
- | * //-sr SEARCH_RANGE_FACTOR//: | + | * // |
+ | * //-sr SEARCH_RANGE_FACTOR//: | ||
+ | |||
===== Help ===== | ===== Help ===== |