Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Annbless committed Nov 30, 2020
0 parents commit 2a013d1
Show file tree
Hide file tree
Showing 521 changed files with 6,471 additions and 0 deletions.
132 changes: 132 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# 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/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
ckpt/
results/
DIFRINT_TEMP/
97 changes: 97 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<h1 align="left">DUT: Learning Video Stabilization by Simply Watching Unstable Videos <a href=""><img src="https://img.shields.io/badge/arXiv-Paper-<COLOR>.svg" ></a> <a href="https://colab.research.google.com/drive/1i-cK-6uFKbWRjxF26uxUqHHSEvq1Ln8h?usp=sharing">
<img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
</a> </h1>

<p align="center">
<a href="#introduction">Introduction</a> |
<a href="#results-demo">Results Demo</a> |
<a href="#installation">Installation</a> |
<a href="#inference-code">Inference Code</a> |
<a href="#news">News</a> |
<a href="#statement">Statement</a> |
<a href="#reference">Reference</a>
</p>

## Introduction

<p align="justify">This repository contains the code, models, test results for the paper <a href="">DUT: Learning Video Stabilization by Simply Watching Unstable Videos</a>. It contains a keypoint detetcion module for robust keypoint detection, a motion propagation module for grid-based trajectories estimation, and a trajectory smoothing module for dynamic trajectory smoothing. The DUT model is totally unsupervised and just need unstable videos for training.

<p align="justify">We have released the inference code, a pretrained model, which can be found in section <a href="#inference-code"><i>inference code</i></a> for more details. The inference code for DIFRINT and StabNet are also included in this repo.</p>

<img src="demo/NetworkStructure.png">

## Results Demo

We test DUT on the NUS dataset and provide a result overview below (odd rows for unstable inputs and even rows for stabilized videos).

<img src="demo/overview1.gif"><img src="demo/overview2.gif"><img src="demo/overview3.gif">

For the motion propagation module, we propose a multi-homography estimation strategy instead of directly using RANSAC for single homography estimation to deal with multiple planes cases. The outliers recognized by RANSAC and the multi-planes identified with the multi-homography strategy are as follows:

<img src="demo/RANSAC.gif" class="left" width='40%'><img src="demo/Cluster.gif" class="right" width='40%'>

The trajectory smoothing module predicts dynamic kernels for iterative smoothing according to the trajectories themselves, the smoothing process can be viewed below:

<img src="demo/Trajectory.gif" width='80%'>

## Installation
Requirements:

- Python 3.6.5+
- Pytorch (version 1.4.0)
- Torchvision (version 0.5.0)

1. Clone this repository

`git clone https://github.com/Annbless/DUTCode.git`

2. Go into the repository

`cd DUTCode`

3. Create conda environment and activate

`conda create -n DUTCode python=3.6.5`

`conda activate DUTCode`

4. Install dependencies

`conda install pytorch==1.4.0 torchvision==0.5.0 cudatoolkit=10.1 -c pytorch`

`pip install -r requirements.txt`

Our code has been tested with Python 3.6.5, Pytorch 1.4.0, Torchvision 0.5.0, CUDA 10.1 on Ubuntu 18.04.


## Inference Code

Here we provide the procedure of testing on sample videos by our pretrained models:

1. Download <a href="https://drive.google.com/drive/folders/15T8Wwf1OL99AKDGTgECzwubwTqbkmGn6?usp=sharing">pretrained model</a> and unzip them to ckpt folder

2. Put clipped frames from unstable videos in the images folder (we have provided one example in the folder)

3. Run the stabilization script

`chmod +x scripts/*`

`./scripts/deploy_samples.sh`

4. The results of our DUT, DIFRINT, and StabNet are provided under the results folder

## News
- [x] release inference code for the DUT model;
- [x] include inference code for the DIFRINT model, thanks to <a href="https://github.com/jinsc37">jinsc37</a>;
- [x] include pytorch version StabNet model, thanks to <a href="https://github.com/cxjyxxme">cxjyxxme</a>;
- [ ] include traditional stabilizers in python;
- [ ] release metrics calculation code;
- [ ] release training code for the DUT model;

## Statement
This project is for research purpose only, please contact us for the licence of commercial use. For any other questions please contact [[email protected]](mailto:[email protected]).

## Reference

- <a href="https://github.com/jinsc37/DIFRINT">DIFRINT</a>
- <a href="https://github.com/cxjyxxme/deep-online-video-stabilization-deploy">StabNet (tensorflow version)</a>
Empty file added configs/__init__.py
Empty file.
89 changes: 89 additions & 0 deletions configs/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from easydict import EasyDict as edict

__C = edict()
cfg = __C

"""
Model options
"""
__C.MODEL = edict()

# gaussian kernel size
__C.MODEL.GAUSSIAN_KSIZE = 15

# gaussian kernel sigma
__C.MODEL.GAUSSIAN_SIGMA = 0.5

# Descriptor Threshold
__C.MODEL.DES_THRSH = 1.0

# Coordinate Threshold
__C.MODEL.COO_THRSH = 5.0

# Ksize
__C.MODEL.KSIZE = 3

# padding
__C.MODEL.padding = 1

# dilation
__C.MODEL.dilation = 1

# scale_list
__C.MODEL.scale_list = [3.0, 5.0, 7.0, 9.0, 11.0, 13.0, 15.0, 17.0, 19.0, 21.0]

# grid size
__C.MODEL.PIXELS = 16

# neighbor radius
__C.MODEL.RADIUS = 200

# input height
__C.MODEL.HEIGHT = 480

# input width
__C.MODEL.WIDTH = 640

# normalization amplitude in optical flow
__C.MODEL.FLOWC = 20

# cluster threshold
__C.MODEL.THRESHOLDPOINT = 102

"""
Training options
"""
__C.TRAIN = edict()

# score strength weight
__C.TRAIN.score_com_strength = 100.0

# scale strength weight
__C.TRAIN.scale_com_strength = 100.0

# non maximum supression threshold
__C.TRAIN.NMS_THRESH = 0.0

# nms kernel size
__C.TRAIN.NMS_KSIZE = 5

# top k patch
__C.TRAIN.TOPK = 512

"""
Threshold options
"""
__C.Threshold = edict()

__C.Threshold.MANG = 2
__C.Threshold.ROT = 5

"""
Infer options
"""
__C.INFER = edict()
__C.INFER.ALLINFER = False
Binary file added demo/Cluster.gif
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 demo/NetworkStructure.png
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 demo/RANSAC.gif
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 demo/Trajectory.gif
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 demo/overview1.gif
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 demo/overview2.gif
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 demo/overview3.gif
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 demo/overview4.gif
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/0.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/1.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/10.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/100.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/101.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/102.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/103.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/104.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/105.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/106.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/107.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/108.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/109.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/11.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/110.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/111.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/112.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/113.jpg
Binary file added images/114.jpg
Binary file added images/115.jpg
Binary file added images/116.jpg
Binary file added images/117.jpg
Binary file added images/118.jpg
Binary file added images/119.jpg
Binary file added images/12.jpg
Binary file added images/120.jpg
Binary file added images/121.jpg
Binary file added images/122.jpg
Binary file added images/123.jpg
Binary file added images/124.jpg
Binary file added images/125.jpg
Binary file added images/126.jpg
Binary file added images/127.jpg
Binary file added images/128.jpg
Binary file added images/129.jpg
Binary file added images/13.jpg
Binary file added images/130.jpg
Binary file added images/131.jpg
Binary file added images/132.jpg
Binary file added images/133.jpg
Binary file added images/134.jpg
Binary file added images/135.jpg
Binary file added images/136.jpg
Binary file added images/137.jpg
Binary file added images/138.jpg
Binary file added images/139.jpg
Binary file added images/14.jpg
Binary file added images/140.jpg
Binary file added images/141.jpg
Binary file added images/142.jpg
Binary file added images/143.jpg
Binary file added images/144.jpg
Binary file added images/145.jpg
Binary file added images/146.jpg
Binary file added images/147.jpg
Binary file added images/148.jpg
Binary file added images/149.jpg
Binary file added images/15.jpg
Binary file added images/150.jpg
Binary file added images/151.jpg
Binary file added images/152.jpg
Binary file added images/153.jpg
Binary file added images/154.jpg
Binary file added images/155.jpg
Binary file added images/156.jpg
Binary file added images/157.jpg
Binary file added images/158.jpg
Binary file added images/159.jpg
Binary file added images/16.jpg
Binary file added images/160.jpg
Binary file added images/161.jpg
Binary file added images/162.jpg
Binary file added images/163.jpg
Binary file added images/164.jpg
Binary file added images/165.jpg
Binary file added images/166.jpg
Binary file added images/167.jpg
Binary file added images/168.jpg
Binary file added images/169.jpg
Binary file added images/17.jpg
Binary file added images/170.jpg
Binary file added images/171.jpg
Binary file added images/172.jpg
Binary file added images/173.jpg
Binary file added images/174.jpg
Binary file added images/175.jpg
Binary file added images/176.jpg
Binary file added images/177.jpg
Binary file added images/178.jpg
Binary file added images/179.jpg
Binary file added images/18.jpg
Binary file added images/180.jpg
Binary file added images/181.jpg
Binary file added images/182.jpg
Binary file added images/183.jpg
Binary file added images/184.jpg
Binary file added images/185.jpg
Binary file added images/186.jpg
Binary file added images/187.jpg
Binary file added images/188.jpg
Binary file added images/189.jpg
Binary file added images/19.jpg
Binary file added images/190.jpg
Binary file added images/191.jpg
Binary file added images/192.jpg
Binary file added images/193.jpg
Binary file added images/194.jpg
Binary file added images/195.jpg
Binary file added images/196.jpg
Binary file added images/197.jpg
Binary file added images/198.jpg
Binary file added images/199.jpg
Binary file added images/2.jpg
Binary file added images/20.jpg
Binary file added images/200.jpg
Binary file added images/201.jpg
Binary file added images/202.jpg
Binary file added images/203.jpg
Binary file added images/204.jpg
Binary file added images/205.jpg
Binary file added images/206.jpg
Binary file added images/207.jpg
Binary file added images/208.jpg
Binary file added images/209.jpg
Binary file added images/21.jpg
Binary file added images/210.jpg
Binary file added images/211.jpg
Binary file added images/212.jpg
Binary file added images/213.jpg
Binary file added images/214.jpg
Binary file added images/215.jpg
Binary file added images/216.jpg
Binary file added images/217.jpg
Binary file added images/218.jpg
Binary file added images/219.jpg
Binary file added images/22.jpg
Binary file added images/220.jpg
Binary file added images/221.jpg
Binary file added images/222.jpg
Binary file added images/223.jpg
Binary file added images/224.jpg
Binary file added images/225.jpg
Binary file added images/226.jpg
Binary file added images/227.jpg
Binary file added images/228.jpg
Binary file added images/229.jpg
Binary file added images/23.jpg
Binary file added images/230.jpg
Binary file added images/231.jpg
Binary file added images/232.jpg
Binary file added images/233.jpg
Binary file added images/234.jpg
Binary file added images/235.jpg
Binary file added images/236.jpg
Binary file added images/237.jpg
Binary file added images/238.jpg
Binary file added images/239.jpg
Binary file added images/24.jpg
Binary file added images/240.jpg
Binary file added images/241.jpg
Binary file added images/242.jpg
Binary file added images/243.jpg
Binary file added images/244.jpg
Binary file added images/245.jpg
Binary file added images/246.jpg
Binary file added images/247.jpg
Binary file added images/248.jpg
Binary file added images/249.jpg
Binary file added images/25.jpg
Binary file added images/250.jpg
Binary file added images/251.jpg
Binary file added images/252.jpg
Binary file added images/253.jpg
Binary file added images/254.jpg
Binary file added images/255.jpg
Binary file added images/256.jpg
Binary file added images/257.jpg
Binary file added images/258.jpg
Binary file added images/259.jpg
Binary file added images/26.jpg
Binary file added images/260.jpg
Binary file added images/261.jpg
Binary file added images/262.jpg
Binary file added images/263.jpg
Binary file added images/264.jpg
Binary file added images/265.jpg
Binary file added images/266.jpg
Binary file added images/267.jpg
Binary file added images/268.jpg
Binary file added images/269.jpg
Binary file added images/27.jpg
Binary file added images/270.jpg
Binary file added images/271.jpg
Binary file added images/272.jpg
Binary file added images/273.jpg
Binary file added images/274.jpg
Binary file added images/275.jpg
Binary file added images/276.jpg
Binary file added images/277.jpg
Binary file added images/278.jpg
Binary file added images/279.jpg
Binary file added images/28.jpg
Binary file added images/280.jpg
Binary file added images/281.jpg
Binary file added images/282.jpg
Binary file added images/283.jpg
Binary file added images/284.jpg
Binary file added images/285.jpg
Binary file added images/286.jpg
Binary file added images/287.jpg
Binary file added images/288.jpg
Binary file added images/289.jpg
Binary file added images/29.jpg
Binary file added images/290.jpg
Binary file added images/291.jpg
Binary file added images/292.jpg
Binary file added images/293.jpg
Binary file added images/294.jpg
Binary file added images/295.jpg
Binary file added images/296.jpg
Binary file added images/297.jpg
Binary file added images/298.jpg
Binary file added images/299.jpg
Binary file added images/3.jpg
Binary file added images/30.jpg
Binary file added images/300.jpg
Binary file added images/301.jpg
Binary file added images/302.jpg
Binary file added images/303.jpg
Binary file added images/304.jpg
Binary file added images/305.jpg
Binary file added images/306.jpg
Binary file added images/307.jpg
Binary file added images/308.jpg
Binary file added images/309.jpg
Binary file added images/31.jpg
Binary file added images/310.jpg
Binary file added images/311.jpg
Binary file added images/312.jpg
Binary file added images/313.jpg
Binary file added images/314.jpg
Binary file added images/315.jpg
Binary file added images/316.jpg
Binary file added images/317.jpg
Binary file added images/318.jpg
Binary file added images/319.jpg
Binary file added images/32.jpg
Binary file added images/320.jpg
Binary file added images/321.jpg
Binary file added images/322.jpg
Binary file added images/323.jpg
Binary file added images/324.jpg
Binary file added images/325.jpg
Binary file added images/326.jpg
Binary file added images/327.jpg
Binary file added images/328.jpg
Binary file added images/329.jpg
Binary file added images/33.jpg
Binary file added images/330.jpg
Binary file added images/331.jpg
Binary file added images/332.jpg
Binary file added images/333.jpg
Binary file added images/334.jpg
Binary file added images/335.jpg
Binary file added images/336.jpg
Binary file added images/337.jpg
Binary file added images/338.jpg
Binary file added images/339.jpg
Binary file added images/34.jpg
Binary file added images/340.jpg
Binary file added images/341.jpg
Binary file added images/342.jpg
Binary file added images/343.jpg
Binary file added images/344.jpg
Binary file added images/345.jpg
Binary file added images/346.jpg
Binary file added images/347.jpg
Binary file added images/348.jpg
Binary file added images/349.jpg
Binary file added images/35.jpg
Binary file added images/350.jpg
Binary file added images/351.jpg
Binary file added images/352.jpg
Binary file added images/353.jpg
Binary file added images/354.jpg
Binary file added images/355.jpg
Binary file added images/356.jpg
Binary file added images/357.jpg
Loading

0 comments on commit 2a013d1

Please sign in to comment.