auto2d_tutorial

This version (2019/08/15 15:36) was approved by twagner.The Previously approved version (2019/07/29 11:18) is available.Diff

How to use SPHIRE's Cinderella

You can find the download and installation instructions here: Download and Installation

I suppose you downloaded the latest classification model.

To run the classification I suppose you want to separate good and bad classes in classes_after_isac.hdf (or any other .mrcs / .hdf file with classes) and you want to save your new .hdf (.mrcs) files into the folder output_folder. Furthermore you want to use the model model.h5 and the GPU with ID=1. Classes with a confidence bigger than 0.7 should be classified as good class.

This is the command to run:

sp_cinderella_predict.py -i path/to/classes_after_isac.hdf -w model.h5 -o output_folder/ -t 0.7 --gpu 1

You will find the files classes_after_isac_good.hdf and classes_after_isac_bad.hdf in your output_folder.

If you would like to train Cinderella with your own classes, you can easily do it. 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.

Then specify the paths into a config file like this:

config.json
{
	"model": {
		"input_size": [75,75]
	},
 
	"train": {
		"batch_size": 32,
		"good_classes": "GOOD_CLASSES/",
		"bad_classes": "BAD_CLASSES/",
		"pretrained_weights": "",
		"saved_weights_name": "my_model.h5",
		"learning_rate": 1e-4,
		"nb_epoch": 100,
		"nb_early_stop": 15
	}
}

The fields have the following meaning:

  • input_size: This is the image size to which each class 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.
  • good_classes: Path to folder with good classes.
  • bad_classes: Path to folder with bad classes.
  • pretrained_weights: Path to weights that are used to initialize the network. It can be empty. As Cinderella is using the same network architecture as crYOLO, we are typically using the general network of crYOLO as pretrained weights.
  • saved_weights_name: Final model filename
  • 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_early_stop: If the validation loss did not improve “nb_early_stop”x in a row, the training will stop automatically.

The next step is to run the training:

sp_cinderella_train.py -c example_config.json --gpu 1

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.

  • auto2d_tutorial.txt
  • Last modified: 2019/08/15 15:36
  • by twagner