Add basic test for aad and unet

This commit is contained in:
henryruhs
2025-03-05 12:53:24 +01:00
parent 786adf73a2
commit 72371b9f11
2 changed files with 36 additions and 2 deletions
+17 -2
View File
@@ -8,12 +8,27 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python 3.10
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: '3.12'
- run: pip install flake8
- run: pip install flake8-import-order
- run: pip install mypy
- run: flake8 embedding_converter face_swapper
- run: mypy embedding_converter face_swapper
test:
strategy:
matrix:
os: [ macos-latest, ubuntu-latest, windows-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: pip install torch torchvision
- run: pip install pytest
- run: pytest
+19
View File
@@ -0,0 +1,19 @@
import torch
import pytest
from face_swapper.src.networks.aad import AAD
from face_swapper.src.networks.unet import UNet
@pytest.mark.parametrize('output_size', [ 256 ])
def test_aad_with_unet(output_size : int) -> None:
generator = AAD(512, 4096, output_size, 2).eval()
encoder = UNet(output_size).eval()
source_tensor = torch.randn(1, 512)
target_tensor = torch.randn(1, 3, output_size, output_size)
target_attributes = encoder(target_tensor)
output_tensor = generator(source_tensor, target_attributes)
assert output_tensor.shape == (1, 3, output_size, output_size)