From 2357b53c9caee3e7962e3470bdfae2c2fcaa8494 Mon Sep 17 00:00:00 2001 From: Dong Date: Wed, 25 Mar 2020 13:59:45 +0800 Subject: [PATCH 1/2] update resnet34 --- README.md | 160 +-------------------------------------- cfgs/resnet18/eval.yaml | 57 -------------- cfgs/resnet18/train.yaml | 73 ------------------ cfgs/resnet50/eval.yaml | 55 -------------- cfgs/resnet50/train.yaml | 73 ------------------ eval.py | 3 - modules/vdn.py | 2 +- train.py | 3 - 8 files changed, 2 insertions(+), 424 deletions(-) delete mode 100644 cfgs/resnet18/eval.yaml delete mode 100644 cfgs/resnet18/train.yaml delete mode 100755 cfgs/resnet50/eval.yaml delete mode 100755 cfgs/resnet50/train.yaml diff --git a/README.md b/README.md index 9f97006..204388d 100755 --- a/README.md +++ b/README.md @@ -1,159 +1 @@ -# Welcome - -This is the codebase of the paper titled "Vector Detection Network: Pointer Detector for Robots Reading Analog Meters in the Wild". -We assume you download it with `git clone `, and the code folder `/VDN` is located in `~`. - -OS: Ubuntu 16.04 or 18.04 -Language: Python 3.6+ -Deep learning framework: PyTorch - -# Prerequisites - -## Hardware - -Make sure the PC is with 8 GB or more GRAM. - -Please make sure you have the correct version of the Nvidia driver installed, and that is compatible with your card. - -## Software - -We use Docker to ease the process of building the environment for running VDN. The installation of Docker can be done by: - -``` -wget -qO- https://get.docker.com/ | sh -systemctl enable docker.service -``` - -Meanwhile, you should also install [nvidia-docker][nv] plugin. To be brief, this is a quick guide: - -``` -# Add the package repositories -curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - - -distribution=$(. /etc/os-release;echo $ID$VERSION_ID) - -curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | \ - sudo tee /etc/apt/sources.list.d/nvidia-docker.list - -sudo apt-get update - -# Install nvidia-docker2 and reload the Docker daemon configuration -sudo apt-get install -y nvidia-docker2 -sudo pkill -SIGHUP dockerd -``` - -Other than that, all software dependence can be handled within the Docker container. -A detailed software dependence list could be found in `VDN/Dockerfile`. -For anonymity concern, we do not provide our docker image, yet you may build one exactly as ours by: - -``` -cd ~/VDN -docker build --tag=vdn/vdn . -``` - -# File structure - -This repo is organized as follows: - -``` -. -+-- cfgs # The configurations of different network architectures -| -+-- compiled # Compiled third-party libraries -| -+-- data -| +-- demo -| +-- result -| -+-- libs # VDN libraries -| -+-- modules # The VDN class -| -+-- utils # Some handy utilities -| -+-- weights -| +-- pretrained -| -+-- .dockerignore -+-- .gitignore -+-- add_aliases.sh # Bash script for adding Docker shortcuts to bash_aliaes -+-- Dockerfile -+-- LICENSE -+-- README.md -| -+-- demo.py # Quick demo for a demonstration -+-- train.py # Training script of VDN -+-- test.py # Evaluation and experiments for VDN - -``` - -# Compile - -We have provided a bash script `add_aliases.sh` to insert some handy bash scripts within the file `~/.bash_aliases`. -It is recommended to do so in the root folder of this project: - -``` -bash add_aliases.sh -source ~/.bash_aliases -``` - -Then, before training or testing VDN, run this to compile the code: - -``` -vdn_compile -``` - -# The Pointer-10K dataset - -The Pointer-10K dataset referred to in our paper is publicly available for non-commercial usage. -If you are interested in the data, please contact us via email. The address will be released afterward. - - -# Basic Training - -Before training the VDN model, (i) make sure you have the Pointer-10K dataset located in `~/Database/Done/pointer_10k`. -(ii) Download the pre-trained ResNet model `resnet50-19c8e357.pth` for parameter initialization from -[torchvision](https://github.com/pytorch/vision/blob/master/torchvision/models/resnet.py) -and put it in `weights/pretrained/` (you may need to create the path manually). - -``` -# start the docker container -vdn_run - -# train -python train.py -``` - -# Run the demo - -To run the demo, put the trained model named as `vdn_best.pth.tar` into `weights/`, and -run the code below - -``` -# start the docker container -vdn_run - -# run the demo within the container -python demo.py -``` - -We provide the model trained by us: [download]() - -You can put your image into `VDN/data/demo`, and the algorithm will automatically find all images within the folder -and detect pointers in these images if any analog meters exist. Please note that VDN takes the image patches output -by a meter detector, with this the provided demo images should contain the whole dial face but not much background -nor only a part of the meters. - -The results of the demo will be output to automatically created folder `output/demo`. - -# Experiments - -You can use the `eval.py` script to perform the experiments conducted in the paper. -For example, to evaluate the performance of the default configuration (ResNet34 backbone -with 384x384 input size), just issue `python eval.py` in the root folder. Evaluations -of ResNet18 and ResNet50 could be executed in the `master` branch, -whereas Res2Net50 is evaluated in individual branch `res2net50`. - -The evaluation output could be found in `/VDN/output/eval-`. - - [nv]: \ No newline at end of file +Please refer to the readme of the master branch. \ No newline at end of file diff --git a/cfgs/resnet18/eval.yaml b/cfgs/resnet18/eval.yaml deleted file mode 100644 index 58fea8f..0000000 --- a/cfgs/resnet18/eval.yaml +++ /dev/null @@ -1,57 +0,0 @@ -GPUS: '0' -OUTPUT_DIR: '/VDN/output/eval-resnet18' -LOG_DIR: '/VDN/logs' -WORKERS: 4 - -DATASET: - DATASET: 'coco' - ROOT: '/Database/Done/pointer_10k' - TRAIN_SET: 'train_pointer' - TEST_SET: 'test_pointer' - ROT_FACTOR: 90 - SCALE_FACTOR: 0.02 -MODEL: - NAME: 'vdn_model' # This name should exist in /VDN/libs/models - PRETRAINED: '/VDN/weights/vdn_model_18_best.pth.tar' - IMAGE_SIZE: - - 384 # width - - 384 # height - NUM_JOINTS: 1 - EXTRA: - TARGET_TYPE: 'gaussian' - HEATMAP_SIZE: - - 96 - - 96 - SIGMA: 3 - FINAL_CONV_KERNEL: 1 - DECONV_WITH_BIAS: false - NUM_DECONV_LAYERS: 3 - NUM_DECONV_FILTERS: - - 256 - - 256 - - 256 - NUM_DECONV_KERNELS: - - 4 - - 4 - - 4 - NUM_LAYERS: 18 -LOSS: - USE_TARGET_WEIGHT: true -TEST: - BATCH_SIZE: 1 - COCO_BBOX_FILE: - BBOX_THRE: 1.0 - FLIP_TEST: false - IMAGE_THRE: 0.0 - IN_VIS_THRE: 0.2 - MODEL_FILE: '' - NMS_THRE: 1.0 - OKS_THRE: 0.9 - USE_GT_BBOX: true -DEBUG: - DEBUG: true - SAVE_BATCH_IMAGES_GT: true - SAVE_BATCH_IMAGES_PRED: true - SAVE_HEATMAPS_GT: true - SAVE_HEATMAPS_PRED: true - diff --git a/cfgs/resnet18/train.yaml b/cfgs/resnet18/train.yaml deleted file mode 100644 index db74e39..0000000 --- a/cfgs/resnet18/train.yaml +++ /dev/null @@ -1,73 +0,0 @@ -GPUS: '0' -OUTPUT_DIR: '/VDN/output/train-resnet18' -LOG_DIR: '/VDN/logs' -WORKERS: 4 - -DATASET: - DATASET: 'coco' - ROOT: '/Database/Done/pointer_10k' - TRAIN_SET: 'train_pointer' - TEST_SET: 'val_pointer' - ROT_FACTOR: 90 - SCALE_FACTOR: 0.02 -MODEL: - NAME: 'vdn_model' - PRETRAINED: '/VDN/weights/pretrained/resnet18-5c106cde.pth' - IMAGE_SIZE: - - 384 # width - - 384 # height - NUM_JOINTS: 1 - EXTRA: - TARGET_TYPE: 'gaussian' - HEATMAP_SIZE: - - 96 - - 96 - SIGMA: 3 - FINAL_CONV_KERNEL: 1 - DECONV_WITH_BIAS: false - NUM_DECONV_LAYERS: 3 - NUM_DECONV_FILTERS: - - 256 - - 256 - - 256 - NUM_DECONV_KERNELS: - - 4 - - 4 - - 4 - NUM_LAYERS: 18 -LOSS: - USE_TARGET_WEIGHT: true -TRAIN: - BATCH_SIZE: 8 - SHUFFLE: true - BEGIN_EPOCH: 0 - END_EPOCH: 200 - RESUME: false - OPTIMIZER: 'adam' - LR: 0.001 - LR_FACTOR: 0.1 - LR_STEP: - - 140 - - 190 - WD: 0.0001 - GAMMA1: 0.99 - GAMMA2: 0.0 - MOMENTUM: 0.9 - NESTEROV: false -TEST: - BATCH_SIZE: 1 - COCO_BBOX_FILE: - BBOX_THRE: 1.0 - FLIP_TEST: false - IMAGE_THRE: 0.0 - IN_VIS_THRE: 0.2 - MODEL_FILE: '' - NMS_THRE: 1.0 - OKS_THRE: 0.9 - USE_GT_BBOX: true -DEBUG: - DEBUG: true - SAVE_BATCH_IMAGES_GT: false - SAVE_BATCH_IMAGES_PRED: false - SAVE_HEATMAPS_GT: false - SAVE_HEATMAPS_PRED: false diff --git a/cfgs/resnet50/eval.yaml b/cfgs/resnet50/eval.yaml deleted file mode 100755 index d877f3c..0000000 --- a/cfgs/resnet50/eval.yaml +++ /dev/null @@ -1,55 +0,0 @@ -GPUS: '0' -OUTPUT_DIR: '/VDN/output/eval-resnet50' -LOG_DIR: '/VDN/logs/eval-resnet50' -WORKERS: 4 - -DATASET: - DATASET: 'coco' - ROOT: '/Database/Done/pointer_10k' - TEST_SET: 'test_pointer' - ROT_FACTOR: 90 - SCALE_FACTOR: 0.02 -MODEL: - NAME: 'vdn_model' # This name should exist in /VDN/libs/models - PRETRAINED: '/VDN/weights/vdn_model_50_best.pth.tar' - IMAGE_SIZE: - - 384 # width - - 384 # height - NUM_JOINTS: 1 - EXTRA: - TARGET_TYPE: 'gaussian' - HEATMAP_SIZE: - - 96 - - 96 - SIGMA: 3 - FINAL_CONV_KERNEL: 1 - DECONV_WITH_BIAS: false - NUM_DECONV_LAYERS: 3 - NUM_DECONV_FILTERS: - - 256 - - 256 - - 256 - NUM_DECONV_KERNELS: - - 4 - - 4 - - 4 - NUM_LAYERS: 50 -LOSS: - USE_TARGET_WEIGHT: true -TEST: - BATCH_SIZE: 1 - COCO_BBOX_FILE: - BBOX_THRE: 1.0 - FLIP_TEST: false - IMAGE_THRE: 0.0 - IN_VIS_THRE: 0.2 - MODEL_FILE: '' - NMS_THRE: 1.0 - OKS_THRE: 0.9 - USE_GT_BBOX: true -DEBUG: - DEBUG: true - SAVE_BATCH_IMAGES_GT: true - SAVE_BATCH_IMAGES_PRED: true - SAVE_HEATMAPS_GT: true - SAVE_HEATMAPS_PRED: true diff --git a/cfgs/resnet50/train.yaml b/cfgs/resnet50/train.yaml deleted file mode 100755 index a9035fe..0000000 --- a/cfgs/resnet50/train.yaml +++ /dev/null @@ -1,73 +0,0 @@ -GPUS: '0' -OUTPUT_DIR: '/VDN/output/train-resnet50' -LOG_DIR: '/VDN/logs' -WORKERS: 4 - -DATASET: - DATASET: 'coco' - ROOT: '/Database/Done/pointer_10k' - TRAIN_SET: 'train_pointer' - TEST_SET: 'val_pointer' - ROT_FACTOR: 90 - SCALE_FACTOR: 0.02 -MODEL: - NAME: 'vdn_model' - PRETRAINED: '/VDN/weights/pretrained/resnet50-19c8e357.pth' - IMAGE_SIZE: - - 384 # width - - 384 # height - NUM_JOINTS: 1 - EXTRA: - TARGET_TYPE: 'gaussian' - HEATMAP_SIZE: - - 96 - - 96 - SIGMA: 3 - FINAL_CONV_KERNEL: 1 - DECONV_WITH_BIAS: false - NUM_DECONV_LAYERS: 3 - NUM_DECONV_FILTERS: - - 256 - - 256 - - 256 - NUM_DECONV_KERNELS: - - 4 - - 4 - - 4 - NUM_LAYERS: 50 -LOSS: - USE_TARGET_WEIGHT: true -TRAIN: - BATCH_SIZE: 8 - SHUFFLE: true - BEGIN_EPOCH: 0 - END_EPOCH: 200 - RESUME: false - OPTIMIZER: 'adam' - LR: 0.001 - LR_FACTOR: 0.1 - LR_STEP: - - 140 - - 190 - WD: 0.0001 - GAMMA1: 0.99 - GAMMA2: 0.0 - MOMENTUM: 0.9 - NESTEROV: false -TEST: - BATCH_SIZE: 1 - COCO_BBOX_FILE: - BBOX_THRE: 1.0 - FLIP_TEST: false - IMAGE_THRE: 0.0 - IN_VIS_THRE: 0.2 - MODEL_FILE: '' - NMS_THRE: 1.0 - OKS_THRE: 0.9 - USE_GT_BBOX: true -DEBUG: - DEBUG: true - SAVE_BATCH_IMAGES_GT: false - SAVE_BATCH_IMAGES_PRED: false - SAVE_HEATMAPS_GT: false - SAVE_HEATMAPS_PRED: false diff --git a/eval.py b/eval.py index ad5ed87..5a403c4 100755 --- a/eval.py +++ b/eval.py @@ -10,9 +10,6 @@ class Test(unittest.TestCase): def test_eval(self): - """Available backbones: resnet34 (default), resnet18, resnet50. - - """ vdn_instance = vdn.VectorDetectionNetwork(backbone='resnet34') vdn_instance.eval() diff --git a/modules/vdn.py b/modules/vdn.py index bbdfc31..110e1c0 100755 --- a/modules/vdn.py +++ b/modules/vdn.py @@ -51,7 +51,7 @@ class VectorDetectionNetwork: """ """ - def __init__(self, train=False, backbone='resnet50'): + def __init__(self, train=False, backbone='resnet34'): if train: vdn_config = os.path.join(root_dir, f"cfgs/{backbone}/train.yaml") else: diff --git a/train.py b/train.py index c99df07..76be9f3 100755 --- a/train.py +++ b/train.py @@ -10,9 +10,6 @@ class Test(unittest.TestCase): def test_train(self): - """Available backbones: resnet34 (default), resnet18, resnet50. - - """ vdn_instance = vdn.VectorDetectionNetwork(train=True, backbone='resnet34') vdn_instance.train() From f729c3c74f5228a525d7cf4018394018c9e275f2 Mon Sep 17 00:00:00 2001 From: dzp Date: Wed, 25 Mar 2020 16:08:43 +0800 Subject: [PATCH 2/2] 325-1-34-140-190-200-0.1 --- cfgs/resnet34/train.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cfgs/resnet34/train.yaml b/cfgs/resnet34/train.yaml index 5e82741..9e9adbb 100755 --- a/cfgs/resnet34/train.yaml +++ b/cfgs/resnet34/train.yaml @@ -41,14 +41,14 @@ TRAIN: BATCH_SIZE: 2 SHUFFLE: true BEGIN_EPOCH: 0 - END_EPOCH: 160 + END_EPOCH: 200 RESUME: false OPTIMIZER: 'adam' LR: 0.001 LR_FACTOR: 0.1 LR_STEP: - - 100 - 140 + - 190 WD: 0.0001 GAMMA1: 0.99 GAMMA2: 0.0 @@ -67,7 +67,7 @@ TEST: USE_GT_BBOX: true DEBUG: DEBUG: true - SAVE_BATCH_IMAGES_GT: true - SAVE_BATCH_IMAGES_PRED: true - SAVE_HEATMAPS_GT: true - SAVE_HEATMAPS_PRED: true + SAVE_BATCH_IMAGES_GT: false + SAVE_BATCH_IMAGES_PRED: false + SAVE_HEATMAPS_GT: false + SAVE_HEATMAPS_PRED: false