Skip to content

Commit 2e4b51f

Browse files
authored
Merge pull request #36 from codelformat/fix/test
Fix/test: improve test coverage
2 parents 9390034 + 35aafd5 commit 2e4b51f

65 files changed

Lines changed: 5558 additions & 5040 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.gitignore‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,7 @@ model/musiq/musiq_spaq_ckpt-358bb6af.pth
2121
VBench
2222
video_detection
2323
watermark/gm/ckpts/model_final.pth
24-
model_from_hf/
24+
model_from_hf/
25+
assets
26+
report.html
27+
.coverage

‎detection/__init__.py‎

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
"""
16-
Detection module for MarkDiffusion.
15+
"""Detection module for watermark verification and extraction."""
1716

18-
This module provides detection functionality for various watermarking algorithms.
19-
"""
20-
21-
__all__ = [
22-
'base',
23-
'gm',
24-
'gs',
25-
'prc',
26-
'ri',
27-
'robin',
28-
'seal',
29-
'sfw',
30-
'tr',
31-
'videomark',
32-
'videoshield',
33-
'wind',
34-
]
17+
from .base import BaseDetector
3518

19+
__all__ = ["BaseDetector"]

‎evaluation/__init__.py‎

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
"""
16-
Evaluation module for MarkDiffusion.
15+
"""Evaluation module for watermark quality and robustness assessment."""
1716

18-
This module provides tools for evaluating watermarking algorithms,
19-
including quality analysis and detection rate calculations.
20-
"""
17+
from .dataset import BaseDataset
2118

22-
__all__ = [
23-
'dataset',
24-
'pipelines',
25-
'tools',
26-
]
19+
__all__ = ["BaseDataset"]

‎evaluation/pipelines/image_quality_analysis.py‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,20 @@
2929
)
3030
import lpips
3131

32+
33+
class SilentProgressBar:
34+
"""A silent progress bar wrapper that supports set_description but shows no output."""
35+
36+
def __init__(self, iterable):
37+
self.iterable = iterable
38+
39+
def __iter__(self):
40+
return iter(self.iterable)
41+
42+
def set_description(self, desc):
43+
"""No-op for silent mode."""
44+
pass
45+
3246
class QualityPipelineReturnType(Enum):
3347
"""Return type of the image quality analysis pipeline."""
3448
FULL = auto()
@@ -120,7 +134,7 @@ def _get_progress_bar(self, iterable):
120134
"""Return an iterable possibly wrapped with a progress bar."""
121135
if self.show_progress:
122136
return tqdm(iterable, desc="Processing", leave=True)
123-
return iterable
137+
return SilentProgressBar(iterable)
124138

125139
def _get_prompt(self, index: int) -> str:
126140
"""Get prompt from dataset."""

‎evaluation/pipelines/video_quality_analysis.py‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,20 @@
1111
import numpy as np
1212
from tqdm import tqdm
1313

14+
15+
class SilentProgressBar:
16+
"""A silent progress bar wrapper that supports set_description but shows no output."""
17+
18+
def __init__(self, iterable):
19+
self.iterable = iterable
20+
21+
def __iter__(self):
22+
return iter(self.iterable)
23+
24+
def set_description(self, desc):
25+
"""No-op for silent mode."""
26+
pass
27+
1428
class QualityPipelineReturnType(Enum):
1529
"""Return type of the image quality analysis pipeline."""
1630
FULL = auto()
@@ -97,7 +111,7 @@ def _get_progress_bar(self, iterable):
97111
"""Return an iterable possibly wrapped with a progress bar."""
98112
if self.show_progress:
99113
return tqdm(iterable, desc="Processing", leave=True)
100-
return iterable
114+
return SilentProgressBar(iterable)
101115

102116
def _get_prompt(self, index: int) -> str:
103117
"""Get prompt from dataset."""

‎evaluation/tools/image_editor.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ def _add_salt_pepper_noise(self, img_array, amount):
212212
pepper_coords_y = np.random.randint(0, h, num_pepper)
213213
pepper_coords_x = np.random.randint(0, w, num_pepper)
214214
noisy[pepper_coords_y, pepper_coords_x] = 0
215-
216-
return noisy
215+
216+
return np.clip(noisy, 0, 255).astype(np.uint8)
217217

218218
def _add_poisson_noise(self, img_array):
219219
vals = len(np.unique(img_array))

0 commit comments

Comments
 (0)