Skip to content

Commit

Permalink
Merge branch 'master' into groups-conv2d
Browse files Browse the repository at this point in the history
  • Loading branch information
Z-Fran authored Feb 23, 2023
2 parents c767ea3 + 6890bc4 commit 2c64c14
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .circleci/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ workflows:
name: minimum_version_cpu
torch: 1.6.0
torchvision: 0.7.0
python: 3.6.9 # The lowest python 3.6.x version available on CircleCI images
python: 3.7.4
requires:
- lint
- build_cpu:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/merge_stage_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
runs-on: ubuntu-18.04
strategy:
matrix:
python-version: [3.6, 3.8, 3.9]
python-version: [3.8, 3.9]
torch: [1.8.1]
include:
- torch: 1.8.1
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repos:
hooks:
- id: flake8
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
rev: 5.11.5
hooks:
- id: isort
- repo: https://github.com/pre-commit/mirrors-yapf
Expand Down
2 changes: 1 addition & 1 deletion README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ MMEditing 同时维护 0.x 和 1.x 版本,详情见[分支维护计划](README

最新的 **0.16.0** 版本已经在 31/10/2022 发布:

- `VisualizationHook` 将被启用,建议用户使用 `MMEditVisualizationHook`
- `VisualizationHook` 将被弃用,建议用户使用 `MMEditVisualizationHook`
- 修复 FLAVR 的注册问题。
- 修正 RDB 模型中的通道数。

Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ def add_mim_extension():
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
Expand Down
4 changes: 4 additions & 0 deletions tests/test_metrics/test_inceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
import numpy as np
import pytest
import torch
from packaging import version

from mmedit.core.evaluation.inceptions import FID, KID, InceptionV3


@pytest.mark.skipif(
version.parse(torch.__version__) <= version.parse('1.5.1'),
reason='torch 1.5.1 do not support interpolation with uint8')
def test_inception():
img1 = np.random.randint(0, 256, (224, 224, 3))
img2 = np.random.randint(0, 256, (224, 224, 3))
Expand Down
108 changes: 55 additions & 53 deletions tests/test_models/test_restorers/test_basic_restorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pytest
import torch
from mmcv.runner import obj_from_dict
from packaging import version

from mmedit.core.evaluation import InceptionV3
from mmedit.models import build_model
Expand Down Expand Up @@ -139,60 +140,61 @@ def test_basic_restorer():
# evaluation with metrics must have gt images
restorer(lq=inputs, test_mode=True)

with tempfile.TemporaryDirectory() as tmpdir:
outputs = restorer(
**data_batch,
test_mode=True,
save_image=True,
save_path=tmpdir,
iteration=None)
assert isinstance(outputs, dict)
assert isinstance(outputs['eval_result'], dict)
assert isinstance(outputs['eval_result']['PSNR'], float)
assert isinstance(outputs['eval_result']['SSIM'], float)

# for feature-based metrics
assert isinstance(outputs['eval_result']['FID'], dict)
assert isinstance(outputs['eval_result']['KID'], dict)
assert '_inception_feat' in restorer.allowed_metrics
assert isinstance(restorer.allowed_metrics['_inception_feat'],
InceptionV3)

incept_result = outputs['eval_result']['_inception_feat']
assert isinstance(incept_result, tuple) and len(incept_result) == 2
for feat in incept_result:
assert isinstance(feat, np.ndarray)
assert feat.shape == (1, 2048)

outputs = restorer(
**data_batch,
test_mode=True,
save_image=True,
save_path=tmpdir,
iteration=100)
assert isinstance(outputs, dict)
assert isinstance(outputs['eval_result'], dict)
assert isinstance(outputs['eval_result']['PSNR'], float)
assert isinstance(outputs['eval_result']['SSIM'], float)

# for feature-based metrics
assert isinstance(outputs['eval_result']['FID'], dict)
assert isinstance(outputs['eval_result']['KID'], dict)
assert '_inception_feat' in restorer.allowed_metrics
assert isinstance(restorer.allowed_metrics['_inception_feat'],
InceptionV3)

incept_result = outputs['eval_result']['_inception_feat']
assert isinstance(incept_result, tuple) and len(incept_result) == 2
for feat in incept_result:
assert isinstance(feat, np.ndarray)
assert feat.shape == (1, 2048)

with pytest.raises(ValueError):
# iteration should be number or None
restorer(
if version.parse(torch.__version__) > version.parse('1.5.1'):
with tempfile.TemporaryDirectory() as tmpdir:
outputs = restorer(
**data_batch,
test_mode=True,
save_image=True,
save_path=tmpdir,
iteration=None)
assert isinstance(outputs, dict)
assert isinstance(outputs['eval_result'], dict)
assert isinstance(outputs['eval_result']['PSNR'], float)
assert isinstance(outputs['eval_result']['SSIM'], float)

# for feature-based metrics
assert isinstance(outputs['eval_result']['FID'], dict)
assert isinstance(outputs['eval_result']['KID'], dict)
assert '_inception_feat' in restorer.allowed_metrics
assert isinstance(restorer.allowed_metrics['_inception_feat'],
InceptionV3)

incept_result = outputs['eval_result']['_inception_feat']
assert isinstance(incept_result, tuple) and len(incept_result) == 2
for feat in incept_result:
assert isinstance(feat, np.ndarray)
assert feat.shape == (1, 2048)

outputs = restorer(
**data_batch,
test_mode=True,
save_image=True,
save_path=tmpdir,
iteration='100')
iteration=100)
assert isinstance(outputs, dict)
assert isinstance(outputs['eval_result'], dict)
assert isinstance(outputs['eval_result']['PSNR'], float)
assert isinstance(outputs['eval_result']['SSIM'], float)

# for feature-based metrics
assert isinstance(outputs['eval_result']['FID'], dict)
assert isinstance(outputs['eval_result']['KID'], dict)
assert '_inception_feat' in restorer.allowed_metrics
assert isinstance(restorer.allowed_metrics['_inception_feat'],
InceptionV3)

incept_result = outputs['eval_result']['_inception_feat']
assert isinstance(incept_result, tuple) and len(incept_result) == 2
for feat in incept_result:
assert isinstance(feat, np.ndarray)
assert feat.shape == (1, 2048)

with pytest.raises(ValueError):
# iteration should be number or None
restorer(
**data_batch,
test_mode=True,
save_image=True,
save_path=tmpdir,
iteration='100')

0 comments on commit 2c64c14

Please sign in to comment.