Update README.md
Browse files
README.md
CHANGED
|
@@ -22,22 +22,26 @@ base_model:
|
|
| 22 |
|
| 23 |
## 🛠️ Usage
|
| 24 |
|
|
|
|
|
|
|
| 25 |
```shell
|
| 26 |
-
|
| 27 |
-
cd memfof
|
| 28 |
-
pip3 install -r requirements.txt
|
| 29 |
```
|
| 30 |
|
|
|
|
|
|
|
| 31 |
```python
|
| 32 |
import torch
|
| 33 |
-
from
|
| 34 |
|
| 35 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 36 |
model = MEMFOF.from_pretrained("egorchistov/optical-flow-MEMFOF-Tartan-T-TSKH-spring").eval().to(device)
|
| 37 |
|
| 38 |
with torch.inference_mode():
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
| 41 |
```
|
| 42 |
|
| 43 |
## 📚 Citation
|
|
|
|
| 22 |
|
| 23 |
## 🛠️ Usage
|
| 24 |
|
| 25 |
+
Install MEMFOF via the package manager:
|
| 26 |
+
|
| 27 |
```shell
|
| 28 |
+
pip3 install git+https://github.com/msu-video-group/memfof
|
|
|
|
|
|
|
| 29 |
```
|
| 30 |
|
| 31 |
+
Then use the following snippet to compute backward and forward optical flow for three consecutive frames:
|
| 32 |
+
|
| 33 |
```python
|
| 34 |
import torch
|
| 35 |
+
from memfof import MEMFOF
|
| 36 |
|
| 37 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 38 |
model = MEMFOF.from_pretrained("egorchistov/optical-flow-MEMFOF-Tartan-T-TSKH-spring").eval().to(device)
|
| 39 |
|
| 40 |
with torch.inference_mode():
|
| 41 |
+
# [B=1, T=3, C=3, H=1080, W=1920]
|
| 42 |
+
example_input = torch.randint(0, 256, [1, 3, 3, 1080, 1920], device=device)
|
| 43 |
+
# [B=1, C=2, H=1080, W=1920]
|
| 44 |
+
backward_flow, forward_flow = model(example_input)["flow"][-1].unbind(dim=1)
|
| 45 |
```
|
| 46 |
|
| 47 |
## 📚 Citation
|