COVID-Next → Pytorch upgrade of the COVID-Net
Inspired by the recent paper COVID-Net: A Tailored Deep Convolutional Neural Network Design for Detection of COVID-19 Cases from Chest Radiography Images and its Tensorflow implementation, we are now open sourcing the upgraded Pytorch version called COVID-Next.
COVID-Next features an architecture that builds upon the famous ResNext50 architecture, which has around 5x less parameters than the original COVID-Net, and achieves comparable performance.
Tensorflow and Pytorch are two major deep learning frameworks and our motivation was to give the Pytorch research community the same starting ground Tensorflow already has when it comes to AI COVID-19 research. As the authors from the paper have already mentioned, this model still doesn't offer production ready performance. The key issue that needs to be resolved is the number of COVID-19 images as the number of such images is currently not diverse and large enough to provide representative prediction results end-users could expect in the production system.
As always, we recommend virtual environments where you install all requirements separately from your system ones. This step is optional :)
To install all requirements, simply run
pip3 install -r requirements.txt.
Code was tested with Python 3.6.9.
Download the pretrained COVID-Next model from here.
Training configuration is currently modified through the
config.py module. Check it out before starting training.
python3 train.py command will run model training.
We have created a script that automates the dataset generation from the two sources referenced in the original repo. To generate the dataset, follow these steps:
- Download the datasets listed below:
- Run the
python3 generate_dataset.py -hto see supported arguments.
The script will create a new folder with
test subfolders where images are located, along with the two metadata files for both train and test subsets.
IO will probably be a bottleneck during training because most of the images are large and a lot of time is wasted on loading images into memory. To avoid this issue, we suggest downscaling images beforehand to input size used by the model.
You can also try to increase the
config.n_threads to alleviate this issue but beware that increasing the number of threads will result in increased memory usage.
The following results were obtained on the dataset used in the original repo as of March 20 2020.
|Accuracy||F1 Macro||Precision Macro||Recall Macro|
Minimal prediction example
You can find the minimal prediction example in
The example demonstrates how to load the model and use it to predict the disease type on the image.
- Training image augmentations
- Pretrained model
- Minimal prediction example
- Loss weights
- Automated dataset generation
- Define train, validation, and test data splits for more proper model evaluation.
- Tensorboard Logging
- Smart sampling