Skip to content

Instantly share code, notes, and snippets.

@lushl9301
Last active November 25, 2017 15:28
Show Gist options
  • Save lushl9301/40d5567ce60b6714b59a5eea7b807262 to your computer and use it in GitHub Desktop.
Save lushl9301/40d5567ce60b6714b59a5eea7b807262 to your computer and use it in GitHub Desktop.
Automated Image Annotation Aide for Chest X-Rays Project README

Prepare data

cd 0.get_data
python2 scraper.py ../data/ims
./clean_name.pl ../data/img
cd ..
jupyter notebook
# run from [1] to [9]

Train CNN

cd 1.cnn
# use the th train256.lua command generated in [9]
# for example
th train256.lua --model nin_bn -s logs/nin_bn_train_1 -b 32 --trainData ../data/iter0_im_tr_sa.csv --testData ../data/iter0_im_val.csv --data_loc ../data/ims --image_size 256 --crop_size 224 --use_pretrained false -r 0.1 --num_labels 17 --do_aug true --max_label 0 --max_2max_ratio 62.07
# this may last for days
# by default use cuda GPU and cudnn library

cp logs/nin_bn_imagenet_lr0.1/model.net ..

Train RNN

cd ../2.rnn/
# Continue with jupyter notebook
# [10] to [15]
th train.lua

The training of RNN will generate model with name like lm_lstm_epoch22.70_3.9726.t7. We will use this model for inference.

Prepare data for next iteration

# Continue with jupyter notebook
# [16] to [18]
cd ../3.prepare_for_next_iter
th sample_for_next_iter.lua -model ../lm_lstm_epoch22.70_3.9726.t7
# will generate lm_lstm_epoch22.70_3.9726.t7_d4nextiter.txt
# Continue with jupyter notebook
# [19] to the end [33]

# reprocess the img data set
./generate_data.py

Re-train CNN

cd ../4.cnn
th train256.lua --model nin_bn -s logs/nin_bn2 -b 32 --trainData ../data/iter1_im_tr_saa1.csv --testData ../data/iter1_im_val.csv --data_loc ../data/ims_preprocessed_iter1 --image_size 256 --crop_size 224 --use_pretrained false -r 0.1 --num_labels 57 --do_aug true --max_label 0

cp logs/nin_bn2/model.net ../model2.net

Re-train RNN

cd ../5.rnn2/
th train.lua

Final inference

th sample.lua
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment