Skip to content

Commit

Permalink
fix demo and update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
xingyizhou committed Jan 24, 2019
1 parent 14420bc commit 9a2b0c4
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 14 deletions.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ The code was tested with [Anaconda](https://www.anaconda.com/download) Python 3.
- Run the demo
~~~
Python demo.py ExtremeNet [--demo /path/to/image/or/folder] [--show_mask]
python demo.py [--demo /path/to/image/or/folder] [--show_mask]
~~~
Contents in `[]` are optional. By default, it runs the sample images provided in `ExtremeNet_ROOT/images/` (from [Detectron](https://github.com/facebookresearch/Detectron/tree/master/demo)). We show the predicted extreme point heatmaps (combined four heatmaps and overlaid on the input image), the predicted center point heatmap, and the detection and octagon mask results. If setup correctly, the output will look like:
Expand Down Expand Up @@ -93,7 +93,7 @@ python setup.up install --user
|-- val2017
|-- test2017
~~~
- Generate extreme point annotation from segmentation:
### Generate extreme point annotation from segmentation:
~~~
cd ExtremeNet_ROOT/tools/
Expand Down Expand Up @@ -124,7 +124,7 @@ After downloading our pre-trained model and the dataset,
## Training
You will need 5 12GB GPUs to reproduce our training. Our model is fine-tuned on the 10-GPU pre-trained [CornerNet model](https://drive.google.com/file/d/1UHjVzSG27Ms0VfSFeGYJ2h2AYZ6d4Le_/view?usp=sharing) (training from scratch may result in 2 AP lower based on our preliminary experiments). After downloading the CornerNet model and put it in `cache/`, run
You will need 5x 12GB GPUs to reproduce our training. Our model is fine-tuned on the 10-GPU pre-trained [CornerNet model](https://drive.google.com/file/d/1UHjVzSG27Ms0VfSFeGYJ2h2AYZ6d4Le_/view?usp=sharing). After downloading the CornerNet model and put it in `cache/`, run
~~~
python train.py ExtremeNet
Expand All @@ -136,6 +136,14 @@ You can resume a half-trained model by
python train.py ExtremeNet --iter xxxx
~~~
### Notes:
- Training takes about 10 days in our Titan V GPUs. Train with 150000 iterations (about 6 days) will be 0.5 AP lower.
- Training from scratch for the same iteration (250000) may result in 2 AP lower than fintuning from CornerNet, but can get higher performance (43.9AP on COCO val w/ multi-scale testing) if trained for (500000 iterations)[https://drive.google.com/file/d/1omiOUjWCrFbTJREypuZaODu0bOlF_7Fg/view?usp=sharing]
- Changing the focal loss (implementation)[https://github.com/xingyizhou/ExtremeNet/blob/master/models/py_utils/kp_utils.py#L428] to (this)[https://github.com/xingyizhou/ExtremeNet/blob/master/models/py_utils/kp_utils.py#L405] can accelerate training, but costs more GPU memory.
## Citation
If you find this model useful for your resesarch, please use the following BibTeX entry.
Expand Down
4 changes: 2 additions & 2 deletions config/ExtremeNet.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"system": {
"dataset": "MSCOCOExtreme",
"batch_size": 38,
"batch_size": 24,
"sampling_function": "kp_detection",

"train_split": "train",
Expand All @@ -19,7 +19,7 @@
"stepsize": 200000,
"snapshot": 50000,

"chunk_sizes": [3, 5, 5, 5, 5, 5, 5, 5],
"chunk_sizes": [4, 5, 5, 5, 5],

"data_dir": "./data",

Expand Down
16 changes: 7 additions & 9 deletions demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,12 @@

def parse_args():
parser = argparse.ArgumentParser(description="Demo CornerNet")
parser.add_argument("--demo", help="demo image path or folders",
default="", type=str)
parser.add_argument("--cfg_file", help="config file",
default='ExtremeNet', type=str)
parser.add_argument("--testiter", dest="testiter",
help="test at iteration i",
default=250000)
parser.add_argument("--demo", help="demo image path or folders",
default="", type=str)
parser.add_argument("--model_path",
default='cache/ExtremeNet_250000.pkl')
parser.add_argument("--show_mask", action='store_true',
help="Run Deep extreme cut to obtain accurate mask")

Expand Down Expand Up @@ -101,13 +100,11 @@ def kp_decode(nnet, images, K, kernel=3, aggr_weight=0.1,
print("system config...")
pprint.pprint(system_configs.full)

test_iter = system_configs.max_iter if args.testiter is None \
else args.testiter
print("loading parameters at iteration: {}".format(test_iter))
print("loading parameters: {}".format(args.model_path))
print("building neural network...")
nnet = NetworkFactory(None)
print("loading parameters...")
nnet.load_params(test_iter)
nnet.load_pretrained_params(args.model_path)
nnet.cuda()
nnet.eval_mode()

Expand Down Expand Up @@ -147,6 +144,7 @@ def kp_decode(nnet, images, K, kernel=3, aggr_weight=0.1,
image_names = [args.demo]

for image_id, image_name in enumerate(image_names):
print('Running ', image_name)
image = cv2.imread(image_name)

height, width = image.shape[0:2]
Expand Down
Binary file added images/16004479832_a748d55f21_k.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/17790319373_bd19b24cfc_k.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/18124840932_e42b3e377c_k.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/19064748793_bb942deea1_k.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/24274813513_0cfd2ce6d0_k.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/33823288584_1d21cf0a26_k.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/33887522274_eebd074106_k.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/34501842524_3c858b3080_k.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions images/NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
The demo images are licensed as United States government work:
https://www.usa.gov/government-works

The image files were obtained on Jan 13, 2018 from the following
URLs.

16004479832_a748d55f21_k.jpg
https://www.flickr.com/photos/archivesnews/16004479832

18124840932_e42b3e377c_k.jpg
https://www.flickr.com/photos/usnavy/18124840932

33887522274_eebd074106_k.jpg
https://www.flickr.com/photos/usaid_pakistan/33887522274

15673749081_767a7fa63a_k.jpg
https://www.flickr.com/photos/usnavy/15673749081

34501842524_3c858b3080_k.jpg
https://www.flickr.com/photos/departmentofenergy/34501842524

24274813513_0cfd2ce6d0_k.jpg
https://www.flickr.com/photos/dhsgov/24274813513

19064748793_bb942deea1_k.jpg
https://www.flickr.com/photos/statephotos/19064748793

33823288584_1d21cf0a26_k.jpg
https://www.flickr.com/photos/cbpphotos/33823288584

17790319373_bd19b24cfc_k.jpg
https://www.flickr.com/photos/secdef/17790319373

0 comments on commit 9a2b0c4

Please sign in to comment.