Skip to content

Instantly share code, notes, and snippets.

@tsaiid
Last active August 16, 2018 02:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsaiid/aa248d54b700ae7fd2bc4bd906328f99 to your computer and use it in GitHub Desktop.
Save tsaiid/aa248d54b700ae7fd2bc4bd906328f99 to your computer and use it in GitHub Desktop.

Prepare

Login as goman

clone repo (only first time)

git clone https://github.com/tsaiid/CheXNet-Keras.git

edit config.ini

主要會動的就是 config.ini 裡的東西

  • image_source_dir 設為影像 pool 的位址 (/home/data/cxr/png/1024)
  • base_model_name 我目前都先用 DenseNet121
  • class_names 就看當下想做哪一種 model,它的架構是可以 train multilabel 的,不過目前我都縮成單一 label
  • batch_size 如果記憶體不夠,可能要降,目前用 32
  • generator_workers 我設成 CPU 的 Thread 數,例如 12,好像會比較快一些

其他基本上沒改。

prepare dataset

它的 dataset csv 檔放在 data/default_split 裡,格式是

Image Index, class_names...
png 檔名, 1 or 0

train.csv 和 dev.csv 是 training 用的,如果要 test 應該要執行 test.py

Into to training environment

nvidia-docker run -it --rm -v /home/data:/data -v /home/goman/CheXNet-Keras:/app --net=host --env KERAS_BACKEND=tensorflow tsaiid/chexnet bash

注意,不是在 /data 或 /app 裡的修改,離開 docker env 後會被清除。

training

python train.py

輸出會在 experiments/1 裡面, weights.h5 會是 loss 最低的,best_weights.h5 會是 validation 中 auc 最好的

testing

python test.py

prediction (not in docker env)

In femh-dicom, modify predict_from_csv.py to load the weights

Usage:

python3 predict_from_csv.py csv_path png_dirpath csv_out_path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment