Init
Browse files
README.md
CHANGED
|
@@ -1,3 +1,41 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# RepNet PyTorch
|
| 2 |
+
A PyTorch port with pre-trained weights of **RepNet**, from *Counting Out Time: Class Agnostic Video Repetition Counting in the Wild* (CVPR 2020) [[paper]](https://arxiv.org/abs/2006.15418) [[project]](https://sites.google.com/view/repnet) [[notebook]](https://colab.research.google.com/github/google-research/google-research/blob/master/repnet/repnet_colab.ipynb#scrollTo=FUg2vSYhmsT0).
|
| 3 |
+
|
| 4 |
+
This repo provides an implementation of RepNet written in PyTorch and a script to convert the pre-trained TensorFlow weights provided by the authors. The outputs of the two implementations are almost identical, with a small deviation (less than $10^{-6}$ at most) probably caused by the [limited precision of floating point operations](https://pytorch.org/docs/stable/notes/numerical_accuracy.html).
|
| 5 |
+
|
| 6 |
+
<div align="center">
|
| 7 |
+
<img src="img/example1.gif" height="160" />
|
| 8 |
+
<img src="img/example2.gif" height="160" />
|
| 9 |
+
<img src="img/example3.gif" height="160" />
|
| 10 |
+
<img src="img/example4.gif" height="160" />
|
| 11 |
+
</div>
|
| 12 |
+
|
| 13 |
+
## Get Started
|
| 14 |
+
- Clone this repo and install dependencies:
|
| 15 |
+
```bash
|
| 16 |
+
git clone https://github.com/materight/RepNet-pytorch
|
| 17 |
+
cd RepNet-pytorch
|
| 18 |
+
pip install -r requirements.txt
|
| 19 |
+
```
|
| 20 |
+
|
| 21 |
+
- To download the TensorFlow pre-trained weights and convert them to PyTorch, run:
|
| 22 |
+
```bash
|
| 23 |
+
python convert_weights.py
|
| 24 |
+
```
|
| 25 |
+
|
| 26 |
+
## Run inference
|
| 27 |
+
Simply run:
|
| 28 |
+
```bash
|
| 29 |
+
python run.py
|
| 30 |
+
```
|
| 31 |
+
The script will download a sample video, run inference on it and save the count visualization. You can also specify a video path as argument (either a local path or a YouTube/HTTP URL):
|
| 32 |
+
```bash
|
| 33 |
+
python run.py --video_path [video_path]
|
| 34 |
+
```
|
| 35 |
+
If the model does not produce good results, try to run the script with more stride values using `--strides`.
|
| 36 |
+
|
| 37 |
+
Example of generated videos showing the repetition count, with the periodicity score and the temporal self-similarity matrix:
|
| 38 |
+
<div align="center">
|
| 39 |
+
<img src="img/example5_score.gif" height="200" />
|
| 40 |
+
<img src="img/example5_tsm.png" height="200" />
|
| 41 |
+
</div>
|