File crowd_counting_error_metrics.py changed (mode: 100644) (index e4cb55b..91ba7e1) |
... |
... |
class CrowdCountingMeanSSIMabs(Metric): |
138 |
138 |
pad_density_map_tensor[:, 0, :y_pred.shape[2],:y_pred.shape[3]] = y_pred |
pad_density_map_tensor[:, 0, :y_pred.shape[2],:y_pred.shape[3]] = y_pred |
139 |
139 |
y_pred = pad_density_map_tensor |
y_pred = pad_density_map_tensor |
140 |
140 |
|
|
141 |
|
ssim_metric = piq.ssim(y, y_pred) |
|
|
141 |
|
ssim_metric = piq.ssim(y, y_pred, reduction=sum()) |
142 |
142 |
|
|
143 |
|
self._sum += ssim_metric.item() * y.shape[0] |
|
|
143 |
|
self._sum += ssim_metric.item() |
144 |
144 |
# we multiply because ssim calculate mean of each image in batch |
# we multiply because ssim calculate mean of each image in batch |
145 |
145 |
# we multiply so we will divide correctly |
# we multiply so we will divide correctly |
146 |
146 |
|
|
|
... |
... |
class CrowdCountingMeanPSNRabs(Metric): |
178 |
178 |
pad_density_map_tensor[:, 0, :y_pred.shape[2], :y_pred.shape[3]] = y_pred |
pad_density_map_tensor[:, 0, :y_pred.shape[2], :y_pred.shape[3]] = y_pred |
179 |
179 |
y_pred = pad_density_map_tensor |
y_pred = pad_density_map_tensor |
180 |
180 |
|
|
181 |
|
psnr_metric = piq.psnr(y, y_pred) |
|
|
181 |
|
psnr_metric = piq.psnr(y, y_pred, reduction=sum()) |
182 |
182 |
|
|
183 |
|
self._sum += psnr_metric.item() * y.shape[0] |
|
|
183 |
|
self._sum += psnr_metric.item() |
184 |
184 |
# we multiply because ssim calculate mean of each image in batch |
# we multiply because ssim calculate mean of each image in batch |
185 |
185 |
# we multiply so we will divide correctly |
# we multiply so we will divide correctly |
186 |
186 |
|
|
|
... |
... |
class CrowdCountingMeanSSIMclamp(Metric): |
218 |
218 |
pad_density_map_tensor[:, 0, :y_pred.shape[2], :y_pred.shape[3]] = y_pred |
pad_density_map_tensor[:, 0, :y_pred.shape[2], :y_pred.shape[3]] = y_pred |
219 |
219 |
y_pred = pad_density_map_tensor |
y_pred = pad_density_map_tensor |
220 |
220 |
|
|
221 |
|
ssim_metric = piq.ssim(y, y_pred) |
|
|
221 |
|
ssim_metric = piq.ssim(y, y_pred, reduction=sum()) |
222 |
222 |
|
|
223 |
|
self._sum += ssim_metric.item() * y.shape[0] |
|
|
223 |
|
self._sum += ssim_metric.item() |
224 |
224 |
# we multiply because ssim calculate mean of each image in batch |
# we multiply because ssim calculate mean of each image in batch |
225 |
225 |
# we multiply so we will divide correctly |
# we multiply so we will divide correctly |
226 |
226 |
|
|
|
... |
... |
class CrowdCountingMeanPSNRclamp(Metric): |
256 |
256 |
pad_density_map_tensor[:, 0, :y_pred.shape[2], :y_pred.shape[3]] = y_pred |
pad_density_map_tensor[:, 0, :y_pred.shape[2], :y_pred.shape[3]] = y_pred |
257 |
257 |
y_pred = pad_density_map_tensor |
y_pred = pad_density_map_tensor |
258 |
258 |
|
|
|
259 |
|
psnr_metric = piq.psnr(y, y_pred, reduction=sum()) |
259 |
260 |
|
|
260 |
|
psnr_metric = piq.psnr(y, y_pred) |
|
261 |
|
|
|
262 |
|
self._sum += psnr_metric.item() * y.shape[0] |
|
|
261 |
|
self._sum += psnr_metric.item() |
263 |
262 |
# we multiply because ssim calculate mean of each image in batch |
# we multiply because ssim calculate mean of each image in batch |
264 |
263 |
# we multiply so we will divide correctly |
# we multiply so we will divide correctly |
265 |
264 |
|
|