Skip to content

Commit 807c6c4

Browse files
lihaipenglihaipeng
lihaipeng
authored and
lihaipeng
committed
Initial commit
0 parents  commit 807c6c4

19 files changed

+2436
-0
lines changed

.gitignore

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
gifs
2+
*.npy
3+
__pycache__
4+
/work/
5+
*.pyc
6+
*.pkl
7+
*.jpg
8+
*.jpeg
9+
*.png
10+
*.json
11+
train_log
12+
*.swp
13+
*.tar
14+
*best-epoch-*
15+
*epoch-*
16+
.DS_Store
17+
.nfs*
18+
.ipynb_checkpoints
19+
*.model
20+
*.gz
21+
*.mp4
22+
test.sh
23+
others
24+
images
25+
*.nori
26+
tmp*.py
27+
*.dlc
28+
*.ipynb*
29+
snpe/
30+
.idea/
31+
*.new
32+
tmp*
33+
result*
34+
data/
35+
experiments/
36+
.env/
37+
gyroFlow
38+
GOF_Clean
39+
GOF_Final

LICENSE

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
This repo is licensed under the Apache License, Version 2.0 (the "License")
2+
3+
Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
4+
5+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6+
7+
8+
Apache License
9+
Version 2.0, January 2004
10+
http://www.apache.org/licenses/
11+
12+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
13+
14+
1. Definitions.
15+
16+
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
17+
18+
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
19+
20+
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
21+
22+
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
23+
24+
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
25+
26+
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
27+
28+
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
29+
30+
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
31+
32+
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
33+
34+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
35+
36+
2. Grant of Copyright License.
37+
38+
Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
39+
40+
3. Grant of Patent License.
41+
42+
Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
43+
44+
4. Redistribution.
45+
46+
You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
47+
48+
You must give any other recipients of the Work or Derivative Works a copy of this License; and
49+
You must cause any modified files to carry prominent notices stating that You changed the files; and
50+
You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
51+
If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
52+
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
53+
54+
5. Submission of Contributions.
55+
56+
Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
57+
58+
6. Trademarks.
59+
60+
This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
61+
62+
7. Disclaimer of Warranty.
63+
64+
Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
65+
66+
8. Limitation of Liability.
67+
68+
In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
69+
70+
9. Accepting Warranty or Additional Liability.
71+
72+
While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
73+
74+
END OF TERMS AND CONDITIONS

README.md

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# [ICCV 2021] GyroFlow: Gyroscope-Guided Unsupervised Optical Flow Learning
2+
3+
This is the official implementation of our ICCV2021 paper [GyroFlow](https://openaccess.thecvf.com/content/ICCV2021/html/Li_GyroFlow_Gyroscope-Guided_Unsupervised_Optical_Flow_Learning_ICCV_2021_paper.html).
4+
5+
Our presentation video: [[Youtube](https://www.youtube.com/watch?v=6gh40PyWdHM)][[Bilibili](https://www.bilibili.com/video/BV1Tr4y127kd/)].
6+
7+
## Our Poster
8+
9+
![image](gyroflow_poster.jpg)
10+
11+
## Dependencies
12+
13+
* MegEngine==1.6.0
14+
* Other requirements please refer to`requirements.txt`.
15+
16+
## Data Preparation
17+
18+
### GOF-Train
19+
20+
2021.11.15: We release the GOF_Train V1 that contains 2000 samples.
21+
22+
The download link is [GoogleDrive](https://drive.google.com/file/d/1eG9W-AlKrQ_fsxT4As6wzGaewCksYxnK/view?usp=sharing). Put the data into `./dataset/GOF_Train`, and the contents of directories are as follows:
23+
24+
```
25+
./dataset/GOF_Train
26+
├── sample_0
27+
│   ├── img1.png
28+
│   ├── img2.png
29+
│   ├── gyro_homo.npy
30+
├── sample_1
31+
│   ├── img1.png
32+
│   ├── img2.png
33+
│   ├── gyro_homo.npy
34+
.....................
35+
├── sample_1999
36+
│   ├── img1.png
37+
│   ├── img2.png
38+
│   ├── gyro_homo.npy
39+
40+
```
41+
42+
### GOF-Clean
43+
44+
For quantitative evaluation, including input frames and the corresponding gyro readings, a ground-truth optical flow is required for each pair.
45+
46+
The download link is [GoogleDrive](https://drive.google.com/file/d/1X9V_DT1JHJti6BeWnWnqAfR4QEzvFQoE/view?usp=sharing). Move the file to `./dataset/GOF_Clean.npy`.
47+
48+
### GOF-Final
49+
50+
The most difficult cases are collected in GOF-Final.
51+
52+
The download link is [GoogleDrive](https://drive.google.com/file/d/1BMuTNygl_W0xWMoHlck_h60inyu7BE1x/view?usp=sharing). Move the file to `./dataset/GOF_Final.npy`.
53+
54+
## Training and Evaluation
55+
56+
### Training
57+
58+
To train the model, you can just run:
59+
60+
```
61+
python train.py --model_dir experiments
62+
```
63+
64+
### Evaluation
65+
66+
Load the pretrained checkpoint and run:
67+
68+
```
69+
python evaluate.py --model_dir experiments --restore_file experiments/val_model_best.pth
70+
```
71+
72+
We've updated the GOF (both trainset and testset), so the performance is a little bit different from the results reported in our paper.
73+
74+
MegEngine checkpoint can be download via [Google Drive]().
75+
76+
## Citation
77+
78+
If you think this work is useful for your research, please kindly cite:
79+
80+
```
81+
@InProceedings{Li_2021_ICCV,
82+
author = {Li, Haipeng and Luo, Kunming and Liu, Shuaicheng},
83+
title = {GyroFlow: Gyroscope-Guided Unsupervised Optical Flow Learning},
84+
booktitle = {Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV)},
85+
month = {October},
86+
year = {2021},
87+
pages = {12869-12878}
88+
}
89+
```
90+
91+
## Acknowledgments
92+
93+
In this project we use (parts of) the official implementations of the following works:
94+
95+
* [ARFlow](https://github.com/lliuz/ARFlow)
96+
* [UpFlow](https://github.com/coolbeam/UPFlow_pytorch)
97+
* [RAFT](https://github.com/princeton-vl/RAFT)
98+
* [DeepOIS](https://github.com/lhaippp/DeepOIS)
99+
100+
We thank the respective authors for open sourcing their methods.

common/__init__.py

Whitespace-only changes.

common/illustrate_results.py

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# -*- coding: utf-8 -*-
2+
# This repo is licensed under the Apache License, Version 2.0 (the "License")
3+
#
4+
# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
5+
#
6+
# Unless required by applicable law or agreed to in writing,
7+
# software distributed under the License is distributed on an
8+
# "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9+
import glob
10+
import json
11+
import os
12+
import time
13+
14+
from prettytable import PrettyTable
15+
16+
17+
def monitor():
18+
total_table = []
19+
for dataset in ['val']:
20+
table = PrettyTable(['exp_name', 'exp_id', 'accuracy'],
21+
sortby='accuracy',
22+
header_style='upper',
23+
valign='m',
24+
title='{} Result'.format(dataset),
25+
reversesort=True)
26+
27+
valid_dirs = [
28+
'experiment_learning_rate',
29+
]
30+
exp_dirs = glob.glob('./experiments/*/exp_*')
31+
exp_dirs = [i for i in exp_dirs if i.split('/')[-2] in valid_dirs]
32+
33+
for exp_dir in exp_dirs:
34+
params_json_path = os.path.join(exp_dir, 'params.json')
35+
results_json_path = os.path.join(exp_dir, 'val_metrics_best.json')
36+
logs_txt_path = os.path.join(exp_dir, 'log.txt')
37+
if not os.path.exists(params_json_path) or not os.path.exists(
38+
results_json_path):
39+
continue
40+
41+
params = json.load(open(params_json_path, 'r'))
42+
results = json.load(open(results_json_path, 'r'))
43+
# exp info
44+
exp_name = exp_dir.split('/')[-2]
45+
exp_id = exp_dir.split('_')[-1]
46+
# model = params['model']
47+
# results
48+
accuracy = '{:>8.4f}'.format(results['accuracy'])
49+
cur_row = [exp_name, exp_id, accuracy]
50+
table.add_row(cur_row)
51+
print(table)
52+
total_table.append(str(table))
53+
54+
55+
def run(interval):
56+
while True:
57+
monitor()
58+
time.sleep(interval)
59+
60+
61+
if __name__ == '__main__':
62+
interval = 10 * 60
63+
run(interval)

0 commit comments

Comments
 (0)