Files
Henry Ruhs 2e6394565a Next (#93)
* add sync batchnorm

* replace random.choice with hash

* fifty percent reduction

* fix discriminator input

* restore dataset.py

* Remove duplicates

* add discriminator_ratio to config

* fix onnx export bug: replace round() with int()

* Fix embedding naming

* Introduce ModelWithConfigCheckpoint callback (#86)

* Fix dist ini

* Style: Refactor typing and improve code clarity in training.py (#88)

* Add type casting for trainer params

* Add type casting for trainer params

* Add type casting for trainer params

* Remove inplace activations for torch.compile compatibility (#89)

* Fix README

* improvise with norm layers & weighted average

* add skip layer

* use gelu instead of leaky_relu

* cleanup

* cleanup

* Update dependencies

* Different defaults and enable validation

* Different defaults and enable validation

* Revert to higher batch size

* Just use copy over copy2

---------

Co-authored-by: harisreedhar <h4harisreedhar.s.s@gmail.com>
Co-authored-by: NeuroDonu <112660822+NeuroDonu@users.noreply.github.com>
Co-authored-by: Harisreedhar <46858047+harisreedhar@users.noreply.github.com>
2025-09-06 19:12:29 +02:00

57 lines
1.4 KiB
Python

from configparser import ConfigParser
import pytest
import torch
from hyperswap.src.networks.aad import AAD
from hyperswap.src.networks.masknet import MaskNet
from hyperswap.src.networks.unet import UNet
@pytest.mark.parametrize('output_size', [ 128, 256, 512 ])
def test_aad_with_unet(output_size : int) -> None:
config_parser = ConfigParser()
config_parser.read_dict(
{
'training.model.generator':
{
'source_channels': '512',
'output_size': str(output_size),
'num_blocks': '2'
}
})
encoder = UNet(config_parser).eval()
generator = AAD(config_parser).eval()
source_tensor = torch.randn(1, 512)
target_tensor = torch.randn(1, 3, output_size, output_size)
target_features = encoder(target_tensor)
output_tensor = generator(source_tensor, target_features)
assert output_tensor.shape == (1, 3, output_size, output_size)
@pytest.mark.parametrize('output_size', [ 128, 256, 512 ])
def test_mask_net(output_size : int) -> None:
config_parser = ConfigParser()
config_parser.read_dict(
{
'training.model.masker':
{
'input_channels': '67',
'output_channels': '1',
'num_filters': '16'
}
})
masker = MaskNet(config_parser).eval()
target_tensor = torch.randn(1, 3, output_size, output_size)
target_feature = torch.randn(1, 64, output_size, output_size)
output_mask = masker(target_tensor, target_feature)
assert output_mask.shape == (1, 1, output_size, output_size)