Cell classifier module of CellNet
In practice, very few people train an entire Convolutional Network from scratch (with random initialization), because it is relatively rare to have a dataset of sufficient size. Instead, it is common to pretrain a ConvNet on a very large dataset (e.g. ImageNet, which contains 1.2 million images with 1000 categories), and then use the ConvNet either as an initialization or a fixed feature extractor for the task of interest.
Futher explanations can be found here.
Open config.py, and edit the lines below to your data directory.
data_base = [:dir to your original dataset]
aug_base = [:dir to your actually trained dataset]
For training, your data file system should be in the following hierarchy. Organizing codes for your data into the given requirements will be provided here
[:data file name]
|-train
|-[:class 0]
|-[:class 1]
|-[:class 2]
...
|-[:class n]
|-val
|-[:class 0]
|-[:class 1]
|-[:class 2]
...
|-[:class n]
After you have cloned the repository, you can train the dataset by running the script below.
You can set the dimension of the additional layer in config.py
The resetClassifier option will automatically detect the number of classes in your data folder and reset the last classifier layer to the according number.
# zero-base training
python main.py --lr [:lr] --depth [:depth] --resetClassifier
# fine-tuning
python main.py --finetune --lr [:lr] --depth [:depth]
# fine-tuning with additional linear layers
python main.py --finetune --addlayer --lr [:lr] --depth [:depth]
Supporting networks
- AlexNet
- VGGNet
- ResNet
- DenseNet
Please modify the scripts and run the line below.
$ ./train/[:network].sh
# For example, if you want to pretrain alexnet, run the code below.
$ ./train/alexnet.sh
For testing out your fine-tuned model on alexnet, VGG(11, 13, 16, 19), ResNet(18, 34, 50, 101, 152),
First, set your data directory as test_dir in config.py.
Please modify the scripts and run the line below.
$ ./test/[:network].sh
For example, if you have trained ResNet with 50 layers, first modify the resnet test script
$ vi ./test/resnet.sh
python main.py \
--net_type resnet \
--depth 50
--testOnly
$ ./test/resnet.sh