Unverified Commit 8fb15457 authored by Tongzhou Wang's avatar Tongzhou Wang Committed by GitHub
Browse files

make_grid should not avoid DBZ by adding eps (#2967)

* make_grid should not avoid DBZ by adding eps

While this doesn't matter in most cases where the images is quantized to [0,255] afterwards, it still is not a faithful de-normalization. It is a simple change to make it use clamp instead.

* fix max/min shadowing
parent 5a4bb19d
...@@ -60,9 +60,9 @@ def make_grid( ...@@ -60,9 +60,9 @@ def make_grid(
assert isinstance(range, tuple), \ assert isinstance(range, tuple), \
"range has to be a tuple (min, max) if specified. min and max are numbers" "range has to be a tuple (min, max) if specified. min and max are numbers"
def norm_ip(img, min, max): def norm_ip(img, low, high):
img.clamp_(min=min, max=max) img.clamp_(min=low, max=high)
img.add_(-min).div_(max - min + 1e-5) img.sub_(low).div_(max(high - low, 1e-5))
def norm_range(t, range): def norm_range(t, range):
if range is not None: if range is not None:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment