User Tools

Site Tools


cinderella_micrographs

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
cinderella_micrographs [2019/12/10 08:58]
twagner
cinderella_micrographs [2019/12/10 09:21]
twagner [Training]
Line 1: Line 1:
 ====== How to use SPHIRE's Cinderella for micrograph selection ====== ====== How to use SPHIRE's Cinderella for micrograph selection ======
  
-This tutorial describes how to use Cinderella to sort micrographs. Unfortunately, we cannot provide a pretrained model yet. Therefore the first step is to train a model (see section //Training//) and to apply a model (see section //Classify//)+This tutorial describes how to use Cinderella to sort micrographs. Unfortunately, we cannot provide a pretrained model yet. Therefore the first step is to train a model (see section //Training//) and to apply a model (see section //Classify//).
  
  
Line 11: Line 11:
 ==== Training ==== ==== Training ====
  
-If you would like to train Cinderella with your own classes, you can easily do it. +The first step is to train Cinderella with manually selected good and bad micrographs. Create two folders, one containing manually selected good micrographs (e.g ''GOOD_MICS/'') and one contain bad micrographs (e.g ''BAD_MICS/''). Both folders can contain subfolders. 
-First you have to separate your good and bad classes into separate files. Create two folders, on containing good classes (e.g ''GOOD_CLASSES/'') and one contain bad classes (e.g ''BAD_CLASSES/''). Both folders can contain multiple .hdf / .mrcs files.+<note question> 
 +**How many micrographs do I need?** 
 + 
 +Good question. 
 +</note>
  
 Then specify the paths into a config file like this: Then specify the paths into a config file like this:
Line 35: Line 39:
 </code> </code>
 The fields have the following meaning: The fields have the following meaning:
-  * **input_size**: This is the image size to which each class is resized to. +  * **input_size**: This is the image size to which each micrograph is resized to. 
-  * **batch_size**: How many classes are in one mini-batch. If you have memory problems, you can try to reduce this value.+  * **batch_size**: How many micrograph are in one mini-batch. If you have memory problems, you can try to reduce this value.
   * **good_path**: Path to folder with good micrographs.   * **good_path**: Path to folder with good micrographs.
   * **bad_path**: Path to folder with bad micrographs.   * **bad_path**: Path to folder with bad micrographs.
Line 43: Line 47:
   * **learning_rate**: Learning rate, should not be changed.   * **learning_rate**: Learning rate, should not be changed.
   * **nb_epoch**: Maximum number of epochs to train. However, it will stop earlier (see nb_early_stop).   * **nb_epoch**: Maximum number of epochs to train. However, it will stop earlier (see nb_early_stop).
-  * **nb_early_stop**: If the validation loss did not improve "nb_early_stop"in a row, the training will stop automatically.+  * **nb_early_stop**: If the validation loss did not improve "nb_early_stop" times in a row, the training will stop automatically.
  
 The next step is to run the training: The next step is to run the training:
Line 51: Line 55:
 </code> </code>
  
-This will train a classification network on the GPU with ID=1. After the training finishes, you get a ''my_model.h5'' file. This can then be used to predict good / bad classes. +This will train a classification network on the GPU with ID=1. After the training finishes, you get a ''my_model.h5'' file. This can then be used to classfiy micrographs into good / bad categories.
  
  
 ==== Classify ==== ==== Classify ====
 +Suppose you want to separate good and bad micrographs in the folder ''micrographs'' and you want to save a list with the filenames of the good / bad micrographgs into the folder ''output_folder''. Furthermore you want to use the model ''my_model.h5'' and the GPU with ID=1. Micrographs with a confidence bigger than 0.5 should be classified as good micrograph.
 +
 +This is the command to run:
 +
 +<code>
 +sp_cinderella_predict.py -i micrographs/ -w model.h5 -o output_folder/ -t 0.5 --gpu 1
 +</code>
 +
 +You will find the files ''bad.txt'' and ''good.txt'' in  your ''output_folder''.
cinderella_micrographs.txt · Last modified: 2020/08/28 07:35 by twagner