Spaces:
Running
Running
Commit ·
b123fa1
1
Parent(s): 0cb72a1
fix(enhance): normalize FFA-Net input like the official test code
Browse filesFFA-Net (official net/test.py) feeds the network RGB [0,1] input normalized
with mean (0.64, 0.6, 0.58) and std (0.14, 0.15, 0.152). Without it the
outdoor weights washed foggy images out (gray-level std 64.8 -> 14.4 on
RTTS BD_Baidu_046) and RTMDet found nothing. With it the image keeps its
contrast (std 67.0) and edges sharpen.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
app.py
CHANGED
|
@@ -331,7 +331,13 @@ def _load_ffa(weights_path: str):
|
|
| 331 |
self.post = nn.Sequential(conv(self.dim, self.dim, k),
|
| 332 |
conv(self.dim, 3, k))
|
| 333 |
|
| 334 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 335 |
x = self.pre(x1)
|
| 336 |
res1 = self.g1(x)
|
| 337 |
res2 = self.g2(res1)
|
|
|
|
| 331 |
self.post = nn.Sequential(conv(self.dim, self.dim, k),
|
| 332 |
conv(self.dim, 3, k))
|
| 333 |
|
| 334 |
+
# Official FFA-Net test.py normalizes the RGB [0,1] input with these
|
| 335 |
+
# statistics; without it the outdoor weights wash the image out.
|
| 336 |
+
MEAN = torch.tensor([0.64, 0.6, 0.58]).view(1, 3, 1, 1)
|
| 337 |
+
STD = torch.tensor([0.14, 0.15, 0.152]).view(1, 3, 1, 1)
|
| 338 |
+
|
| 339 |
+
def forward(self, x):
|
| 340 |
+
x1 = (x - self.MEAN.to(x.device)) / self.STD.to(x.device)
|
| 341 |
x = self.pre(x1)
|
| 342 |
res1 = self.g1(x)
|
| 343 |
res2 = self.g2(res1)
|