**DOCUMENTATION OUTDATED** The documentation has moved to https://cryolo.readthedocs.io ===== 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 robust set of generic features. The last layers, however, learn a fairly abstract representation of the particles and it might be that they do not perfectly fit your particle at hand. In order to adapt this abstract representation within the network to your specific particle, fine-tuning only affects the last convolutional layers, but keeps all others fixed. 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 the required 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. The fine tune mode is still somewhat experimental and we will update this section as crYOLO develops over time. If you followed the installation instructions, you now have to activate the cryolo virtual environment with source activate cryolo ==== 1. Data preparation ==== {{page>pipeline:window:cryolo:data_preparation}} ==== 2. Start crYOLO ==== {{page>pipeline:window:cryolo:start_cryolo}} ==== 3. 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.
► You can now press the [Start] button to create configuration file.
Alternative: 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: cryolo_gui.py config config_cryolo.json 160 --train_image_folder train_image --train_annot_folder train_annot --pretrained_weights gmodel_phosnet_20190516.h5 To get a full description of all available options type: cryolo_gui.py config -h If you want to specify seperate validation folders you can use the %%--%%valid_image_folder and %%--%%valid_annot_folder options: cryolo_gui.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
==== 4. 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 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:cryolo_refine_202003.png?700 |}} In the //"Optional arguments"// tab please check the fine_tune box. {{ :pipeline:window:cryolo_refine_02.png?300 |}} **Adjust the number of layers to train** 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. **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.
► You can now press the [Start] button to start training.
Alternative: 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 ): cryolo_train.py -c config.json -w 0 -g 0 --fine_tune -lft 2
==== 5. Picking ==== {{page>pipeline:window:cryolo:picking}} ==== 6. Visualize the results ==== {{page>pipeline:window:cryolo:visualize}} ==== 7. Evaluate your results ==== {{page>pipeline:window:cryolo:evaluate_results}}