Skip to content

Commit cf49b54

Browse files
Updates and fixes for newer PyTorch versions. Using PyTorch's tensorboard instead of TensorboardX.
1 parent 8370fe9 commit cf49b54

File tree

8 files changed

+26
-26
lines changed

8 files changed

+26
-26
lines changed

INSTALL.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ conda install pytorch torchvision cudatoolkit=10.0 -c pytorch
2323
- It is possible to use any PyTorch supported version of CUDA (not necessarily v10).
2424
- For more details about PyTorch installation, see https://pytorch.org/get-started/previous-versions/.
2525

26-
#### Install matplotlib, pandas, opencv, visdom and tensorboadX
26+
#### Install matplotlib, pandas, opencv, visdom and tensorboad
2727
```bash
2828
conda install matplotlib pandas
29-
pip install opencv-python tensorboardX visdom
29+
pip install opencv-python visdom tb-nightly
3030
```
3131

3232

INSTALL_win.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ conda install pytorch torchvision cudatoolkit=10.0 -c pytorch
2525
- It is possible to use any PyTorch supported version of CUDA (not necessarily v10), but better be the same version with your preinstalled CUDA (if you have one)
2626
- For more details about PyTorch installation, see https://pytorch.org/get-started/previous-versions/.
2727

28-
#### Install matplotlib, pandas, opencv, visdom and tensorboadX
28+
#### Install matplotlib, pandas, opencv, visdom and tensorboad
2929
```bash
3030
conda install matplotlib pandas
31-
pip install opencv-python tensorboardX visdom
31+
pip install opencv-python visdom tb-nightly
3232
```
3333

3434

README.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
# PyTracking
22
A general python framework for training and running visual object trackers, based on **PyTorch**.
3-
4-
### **News:** Code released for **DiMP**!!!
5-
Code now released for our new tracker **DiMP**, accepted as an Oral at ICCV 2019.
6-
This release also includes many **new features**, including:
7-
* Visualization with Visdom
8-
* VOT integration
9-
* Many new network modules
10-
* Multi GPU training
11-
* PyTorch v1.2 support
12-
133

144
## Highlights
155

install.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ pip install opencv-python
3939

4040
echo ""
4141
echo ""
42-
echo "****************** Installing tensorboardX ******************"
43-
pip install tensorboardX
42+
echo "****************** Installing tensorboard ******************"
43+
pip install tb-nightly
4444

4545
echo ""
4646
echo ""

ltr/admin/loading.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,16 @@
33
import sys
44
from pathlib import Path
55
import importlib
6+
import inspect
67

78

9+
def load_trained_network(workspace_dir, network_path, checkpoint=None):
10+
checkpoint_dir = os.path.join(workspace_dir, 'checkpoints')
11+
directory = '{}/{}'.format(checkpoint_dir, network_path)
12+
13+
net, _ = load_network(directory, checkpoint)
14+
return net
15+
816
def load_network(network_dir=None, checkpoint=None, constructor_fun_name=None, constructor_module=None, **kwargs):
917
"""Loads a network checkpoint file.
1018
@@ -18,6 +26,7 @@ def load_network(network_dir=None, checkpoint=None, constructor_fun_name=None, c
1826
The extra keyword arguments are supplied to the network constructor to replace saved ones.
1927
"""
2028

29+
2130
if network_dir is not None:
2231
net_path = Path(network_dir)
2332
else:
@@ -58,14 +67,16 @@ def load_network(network_dir=None, checkpoint=None, constructor_fun_name=None, c
5867
net_constr.fun_name = constructor_fun_name
5968
if constructor_module is not None:
6069
net_constr.fun_module = constructor_module
61-
for arg, val in kwargs.items():
62-
if arg in net_constr.kwds.keys():
63-
net_constr.kwds[arg] = val
64-
else:
65-
print('WARNING: Keyword argument "{}" not found when loading network.'.format(arg))
6670
# Legacy networks before refactoring
6771
if net_constr.fun_module.startswith('dlframework.'):
6872
net_constr.fun_module = net_constr.fun_module[len('dlframework.'):]
73+
net_fun = getattr(importlib.import_module(net_constr.fun_module), net_constr.fun_name)
74+
net_fun_args = list(inspect.signature(net_fun).parameters.keys())
75+
for arg, val in kwargs.items():
76+
if arg in net_fun_args:
77+
net_constr.kwds[arg] = val
78+
else:
79+
print('WARNING: Keyword argument "{}" not found when loading network. It was ignored.'.format(arg))
6980
net = net_constr.get()
7081
else:
7182
raise RuntimeError('No constructor for the given network.')
@@ -118,4 +129,4 @@ def _cleanup_legacy_env():
118129
if m.startswith('dlframework'):
119130
del_modules.append(m)
120131
for m in del_modules:
121-
del sys.modules[m]
132+
del sys.modules[m]

ltr/admin/tensorboard.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22
from collections import OrderedDict
3-
from tensorboardX import SummaryWriter
3+
from torch.utils.tensorboard import SummaryWriter
44

55

66
class TensorboardWriter:

ltr/models/target_classifier/optimizer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def forward(self, weights, feat, bb, sample_weight=None, num_iter=None, compute_
148148
scores_grad = sample_weight * (score_mask * scores_grad)
149149

150150
# Compute optimal step length
151-
alpha_num = (weights_grad * weights_grad).view(num_sequences, -1).sum(dim=1)
151+
alpha_num = (weights_grad * weights_grad).sum(dim=(1,2,3))
152152
alpha_den = ((scores_grad * scores_grad).view(num_images, num_sequences, -1).sum(dim=(0,2)) + reg_weight * alpha_num).clamp(1e-8)
153153
alpha = alpha_num / alpha_den
154154

pytracking/libs/operation.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,4 @@ def conv1x1(input: torch.Tensor, weight: torch.Tensor):
3939
if weight is None:
4040
return input
4141

42-
return torch.matmul(weight.view(weight.shape[0], weight.shape[1]),
43-
input.view(input.shape[0], input.shape[1], -1)).view(input.shape[0], weight.shape[0], input.shape[2], input.shape[3])
42+
return torch.conv2d(input, weight)

0 commit comments

Comments
 (0)