Skip to content

pudae/tensorflow-densenet

Repository files navigation

Tensorflow-DenseNet with ImageNet Pretrained Models

This is an Tensorflow implementation of DenseNet by G. Huang, Z. Liu, K. Weinberger, and L. van der Maaten with ImageNet pretrained models. The weights are converted from DenseNet-Keras Models.

The code are largely borrowed from TensorFlow-Slim Models.

Pre-trained Models

The top-1/5 accuracy rates by using single center crop (crop size: 224x224, image size: 256xN)

Network Top-1 Top-5 Checkpoints
DenseNet 121 (k=32) 74.91 92.19 model
DenseNet 169 (k=32) 76.09 93.14 model
DenseNet 161 (k=48) 77.64 93.79 model

Usage

Follow the instruction TensorFlow-Slim Models.

Step-by-step Example of training on flowers dataset.

Downloading ans converting flowers dataset

$ DATA_DIR=/tmp/data/flowers
$ python download_and_convert_data.py \
    --dataset_name=flowers \
    --dataset_dir="${DATA_DIR}"

Training a model from scratch.

$ DATASET_DIR=/tmp/data/flowers
$ TRAIN_DIR=/tmp/train_logs
$ python train_image_classifier.py \
    --train_dir=${TRAIN_DIR} \
    --dataset_name=flowers \
    --dataset_split_name=train \
    --dataset_dir=${DATASET_DIR} \
    --model_name=densenet121 

Fine-tuning a model from an existing checkpoint

$ DATASET_DIR=/tmp/data/flowers
$ TRAIN_DIR=/tmp/train_logs
$ CHECKPOINT_PATH=/tmp/my_checkpoints/tf-densenet121.ckpt
$ python train_image_classifier.py \
    --train_dir=${TRAIN_DIR} \
    --dataset_name=flowers \
    --dataset_split_name=train \
    --dataset_dir=${DATASET_DIR} \
    --model_name=densenet121 \
    --checkpoint_path=${CHECKPOINT_PATH} \
    --checkpoint_exclude_scopes=global_step,densenet121/logits \
    --trainable_scopes=densenet121/logits

About

Tensorflow-DenseNet with ImageNet Pretrained Models

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages