Skip to content

Commit

Permalink
Add GH workflow to run tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DaWelter committed Nov 1, 2024
1 parent 9891d60 commit 4b92feb
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 4 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Tests

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
workflow_dispatch:

jobs:
tests:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python Env
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: 'pip'

- name: Install Python Dependencies
run: pip install -r requirements.txt

- name: Install
run: python -m pip install -e .

- name: Test
run: python -m pytest $GITHUB_WORKSPACE/test/
15 changes: 15 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--extra-index-url https://download.pytorch.org/whl/cpu
torch
torchvision
scipy
numpy
opencv-python
kornia
matplotlib
tqdm
h5py
onnx
onnxruntime
strenum
tabulate
pytest
2 changes: 1 addition & 1 deletion scripts/export_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def clear_denormals(state_dict, threshold=1.e-20):
mask = torch.abs(v) > threshold
n = torch.count_nonzero(~mask)
if n:
print (f"{k:40s}: {n:10d} ({n/np.product(v.shape)*100}%)")
print (f"{k:40s}: {n:10d} ({n/np.prod(v.shape)*100}%)")
v *= mask.to(torch.float32)
return state_dict

Expand Down
2 changes: 1 addition & 1 deletion test/test_dshdf5pose.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def mytrafo(sample):

ds = dshdf5pose.Hdf5PoseDataset(filename, transform = mytrafo, dataclass = 42)

assert np.alltrue(ds.sequence_starts == np.asarray(sequence_starts))
assert np.all(ds.sequence_starts == np.asarray(sequence_starts))

sample = ds[0]
assert isinstance(sample, batch.Batch)
Expand Down
2 changes: 1 addition & 1 deletion test/test_models_sanity.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def timing_and_output(net, x):


def backprop(net):
device = 'cuda'
device = 'cuda' if torch.cuda.is_available() else 'cpu'
B = 16
net = copy.deepcopy(net)
net.train()
Expand Down
2 changes: 1 addition & 1 deletion trackertraincode/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def __init__(self, fov):
self.f = 1. / math.tan(fov*math.pi/180.*0.5)

def corrected_rotation(self, image_sizes : Tensor, coord : Tensor, pose : Tensor):
'''
r'''
Explanation though top view
^ face-local z-axis
z-axis ^ | ^ direction under which the CNN "sees" the face through it's crop
Expand Down

0 comments on commit 4b92feb

Please sign in to comment.