-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
yangxue
committed
Apr 25, 2019
0 parents
commit 5d5ecce
Showing
170 changed files
with
63,981 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
env/ | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
.hypothesis/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# celery beat schedule file | ||
celerybeat-schedule | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# dotenv | ||
.env | ||
|
||
# virtualenv | ||
.venv | ||
venv/ | ||
ENV/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
|
||
.pyc | ||
.so | ||
*.data-00000-of-00001 | ||
*.index | ||
*.meta | ||
events.* | ||
checkpoint | ||
.idea/ | ||
__pycache__/ | ||
*.json | ||
*.zip | ||
|
||
*/tools/demos/* | ||
*/output/* | ||
*/data/pretrained_weights/* | ||
*/data/tfrecord/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018 DetectionTeamUCAS | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# Cascade R-CNN: Delving into High Quality Object Detection | ||
|
||
## Abstract | ||
This repo is based on [FPN](https://github.com/DetectionTeamUCAS/FPN_Tensorflow), and completed by [YangXue](https://github.com/yangxue0827). | ||
|
||
## Train on COCO train2017 and test on COCO val2017 (coco minival). | ||
|Model|Backbone|Train Schedule|GPU|Image/GPU|FP16|Box AP(Mask AP)|test stage| | ||
|-----|--------|--------------|---|---------|----|---------------|---| | ||
|Faster (paper)|R50v1-FPN|1X|8X TITAN XP|1|no|38.3|3| | ||
|Faster (ours)|R50v1-FPN|1X|8X 2080 Ti|1|no|38.2|3| | ||
|Faster (Face++)|R50v1-FPN|1X|8X 2080 Ti|2|no|39.1|3| | ||
|
||
![2](comparison.png) | ||
|
||
## My Development Environment | ||
1、python3.5 (anaconda recommend) | ||
2、cuda9.0 **(If you want to use cuda8, please set CUDA9 = False in the cfgs.py file.)** | ||
3、[opencv(cv2)](https://pypi.org/project/opencv-python/) | ||
4、[tfplot](https://github.com/wookayin/tensorflow-plot) | ||
5、tensorflow == 1.12 | ||
|
||
## Download Model | ||
### Pretrain weights | ||
1、Please download [resnet50_v1](http://download.tensorflow.org/models/resnet_v1_50_2016_08_28.tar.gz), [resnet101_v1](http://download.tensorflow.org/models/resnet_v1_101_2016_08_28.tar.gz) pre-trained models on Imagenet, put it to data/pretrained_weights. | ||
2、Or you can choose to use a better backbone, refer to [gluon2TF](https://github.com/yangJirui/gluon2TF). [Pretrain Model Link](https://pan.baidu.com/s/1HF3G5XSxXm7W4pk10RuOlw), password: q4jg. | ||
|
||
### Trained weights | ||
**Select a configuration file in the folder ($PATH_ROOT/libs/configs/) and copy its contents into cfgs.py, then download the corresponding [weights](https://github.com/DetectionTeamUCAS/Models/tree/master/Cascade_FPN_Tensorflow).** | ||
|
||
## Compile | ||
``` | ||
cd $PATH_ROOT/libs/box_utils/cython_utils | ||
python setup.py build_ext --inplace | ||
``` | ||
|
||
## Train | ||
|
||
1、If you want to train your own data, please note: | ||
``` | ||
(1) Modify parameters (such as CLASS_NUM, DATASET_NAME, VERSION, etc.) in $PATH_ROOT/libs/configs/cfgs.py | ||
(2) Add category information in $PATH_ROOT/libs/label_name_dict/lable_dict.py | ||
(3) Add data_name to $PATH_ROOT/data/io/read_tfrecord_multi_gpu.py | ||
``` | ||
|
||
2、make tfrecord | ||
``` | ||
cd $PATH_ROOT/data/io/ | ||
python convert_data_to_tfrecord_coco.py --VOC_dir='/PATH/TO/JSON/FILE/' | ||
--save_name='train' | ||
--dataset='coco' | ||
``` | ||
|
||
3、multi-gpu train | ||
``` | ||
cd $PATH_ROOT/tools | ||
python multi_gpu_train.py | ||
``` | ||
|
||
## Eval | ||
``` | ||
cd $PATH_ROOT/tools | ||
python eval_coco.py --eval_data='/PATH/TO/IMAGES/' | ||
--eval_gt='/PATH/TO/TEST/ANNOTATION/' | ||
--GPU='0' | ||
``` | ||
|
||
## Tensorboard | ||
``` | ||
cd $PATH_ROOT/output/summary | ||
tensorboard --logdir=. | ||
``` | ||
![3](images.png) | ||
|
||
![4](scalars.png) | ||
|
||
## Reference | ||
1、https://github.com/endernewton/tf-faster-rcnn | ||
2、https://github.com/zengarden/light_head_rcnn | ||
3、https://github.com/tensorflow/models/tree/master/research/object_detection | ||
4、https://github.com/CharlesShang/FastMaskRCNN | ||
5、https://github.com/matterport/Mask_RCNN | ||
6、https://github.com/msracver/Deformable-ConvNets | ||
7、https://github.com/tensorpack/tensorpack |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
import json | ||
import os | ||
import cv2 | ||
from xml.dom.minidom import Document | ||
import xml.dom.minidom | ||
|
||
label_map = {'bus': 1, 'traffic light': 2, 'traffic sign': 3, 'person': 4, 'bike': 5, | ||
'truck': 6, 'motor': 7, 'car': 8, 'train': 9, 'rider': 10} | ||
FLAG = ['train', 'val'] | ||
|
||
|
||
def write_xml(save_path, name, box_list, label_list, w, h, d): | ||
|
||
# dict_box[filename]=json_dict[filename] | ||
doc = xml.dom.minidom.Document() | ||
root = doc.createElement('annotation') | ||
doc.appendChild(root) | ||
|
||
foldername = doc.createElement("folder") | ||
foldername.appendChild(doc.createTextNode("JPEGImages")) | ||
root.appendChild(foldername) | ||
|
||
nodeFilename = doc.createElement('filename') | ||
nodeFilename.appendChild(doc.createTextNode(name)) | ||
root.appendChild(nodeFilename) | ||
|
||
pathname = doc.createElement("path") | ||
pathname.appendChild(doc.createTextNode("xxxx")) | ||
root.appendChild(pathname) | ||
|
||
sourcename=doc.createElement("source") | ||
|
||
databasename = doc.createElement("database") | ||
databasename.appendChild(doc.createTextNode("Unknown")) | ||
sourcename.appendChild(databasename) | ||
|
||
annotationname = doc.createElement("annotation") | ||
annotationname.appendChild(doc.createTextNode("xxx")) | ||
sourcename.appendChild(annotationname) | ||
|
||
imagename = doc.createElement("image") | ||
imagename.appendChild(doc.createTextNode("xxx")) | ||
sourcename.appendChild(imagename) | ||
|
||
flickridname = doc.createElement("flickrid") | ||
flickridname.appendChild(doc.createTextNode("0")) | ||
sourcename.appendChild(flickridname) | ||
|
||
root.appendChild(sourcename) | ||
|
||
nodesize = doc.createElement('size') | ||
nodewidth = doc.createElement('width') | ||
nodewidth.appendChild(doc.createTextNode(str(w))) | ||
nodesize.appendChild(nodewidth) | ||
nodeheight = doc.createElement('height') | ||
nodeheight.appendChild(doc.createTextNode(str(h))) | ||
nodesize.appendChild(nodeheight) | ||
nodedepth = doc.createElement('depth') | ||
nodedepth.appendChild(doc.createTextNode(str(d))) | ||
nodesize.appendChild(nodedepth) | ||
root.appendChild(nodesize) | ||
|
||
segname = doc.createElement("segmented") | ||
segname.appendChild(doc.createTextNode("0")) | ||
root.appendChild(segname) | ||
|
||
for (box, label) in zip(box_list, label_list): | ||
|
||
nodeobject = doc.createElement('object') | ||
nodename = doc.createElement('name') | ||
nodename.appendChild(doc.createTextNode(str(label))) | ||
nodeobject.appendChild(nodename) | ||
nodebndbox = doc.createElement('bndbox') | ||
nodex1 = doc.createElement('x1') | ||
nodex1.appendChild(doc.createTextNode(str(box[0]))) | ||
nodebndbox.appendChild(nodex1) | ||
nodey1 = doc.createElement('y1') | ||
nodey1.appendChild(doc.createTextNode(str(box[1]))) | ||
nodebndbox.appendChild(nodey1) | ||
nodex2 = doc.createElement('x2') | ||
nodex2.appendChild(doc.createTextNode(str(box[2]))) | ||
nodebndbox.appendChild(nodex2) | ||
nodey2 = doc.createElement('y2') | ||
nodey2.appendChild(doc.createTextNode(str(box[3]))) | ||
nodebndbox.appendChild(nodey2) | ||
|
||
nodeobject.appendChild(nodebndbox) | ||
root.appendChild(nodeobject) | ||
fp = open(save_path, 'w') | ||
doc.writexml(fp, indent='\n') | ||
fp.close() | ||
|
||
|
||
for flag in FLAG: | ||
BDD_path = '/unsullied/sharefs/_research_detection/GeneralDetection/BDD100K/bdd100k/' | ||
BDD_labels_dir = os.path.join(BDD_path, 'labels/bdd100k_labels_images_{}.json'.format(flag)) | ||
BDD_labels = json.load(open(BDD_labels_dir, 'r')) | ||
BDD_images_dir = os.path.join(BDD_path, 'images/100k/{}'.format(flag)) | ||
|
||
for cnt, bdd in enumerate(BDD_labels): | ||
img_name = bdd['name'] | ||
img_path = os.path.join(BDD_images_dir, img_name) | ||
# img = cv2.imread(img_path) | ||
# h, w, d = img.shape | ||
h, w, d = 720, 1280, 3 | ||
bdd_boxes = bdd['labels'] | ||
box_list, label_list = [], [] | ||
for bb in bdd_boxes: | ||
if bb['category'] not in label_map.keys(): | ||
continue | ||
box = bb['box2d'] | ||
box_list.append([round(box['x1']), round(box['y1']), | ||
round(box['x2']), round(box['y2'])]) | ||
label_list.append(bb['category']) | ||
|
||
if len(box_list) != 0: | ||
save_path = os.path.join('/unsullied/sharefs/yangxue/isilon/yangxue/data/BDD100K/BDD100K_VOC/bdd100k_{}/Annotations'.format(flag), | ||
img_name.replace('.jpg', '.xml')) | ||
write_xml(save_path, img_name, box_list, label_list, w, h, d) | ||
if cnt % 100 == 0: | ||
print('{} process: {}/{}'.format(flag, cnt+1, len(BDD_labels))) | ||
print('Finish!') | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Oops, something went wrong.