You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
assert (len(filenames) > 0) # no images found in the given directory
for filename in filenames:
if os.path.splitext(filename)[1].lower() in supportedFormats:
image = Image(path + '/' + filename, device, maxRes)
`
When the folder is read, width is initialized to None, and the first image is read in with the initial value, and all subsequent images are asserted according to this value.
Suppose all resize is 256 px, and I input an image (not the first one) of 1935 px * 1935 px. scale is 256/1935 = 0.13229974160206717 (probably related to decimal representation precision). Then, int(image.shape[1] * scale) = int(255.999999999999999997) = 255.
assert image.width == width and image.height == height would be an error. Because 255 is not equal to 256.
Maybe it is better to resize to targetResolution directly or use the round function instead of int().
The text was updated successfully, but these errors were encountered:
image.py
`
def resizeImage(image, targetResolution):
'''
resize an image (as numpy array) to the target resolution
:param image: numpy array [h, w, 4/3/1]
:param targetResolution: int > 0
:return: numpy array [h, w, 4/3/1]
'''
assert(image is not None and isinstance(image, np.ndarray) and len(image.shape) == 3 and image.shape[-1] == 3 or image.shape[-1] == 4 or image.shape[-1] == 1)
dmax = max(image.shape[0], image.shape[1])
and
width = None
height = None
ct = 0
assert (len(filenames) > 0) # no images found in the given directory
for filename in filenames:
if os.path.splitext(filename)[1].lower() in supportedFormats:
image = Image(path + '/' + filename, device, maxRes)
`
When the folder is read, width is initialized to None, and the first image is read in with the initial value, and all subsequent images are asserted according to this value.
Suppose all resize is 256 px, and I input an image (not the first one) of 1935 px * 1935 px. scale is 256/1935 = 0.13229974160206717 (probably related to decimal representation precision). Then, int(image.shape[1] * scale) = int(255.999999999999999997) = 255.
assert image.width == width and image.height == height would be an error. Because 255 is not equal to 256.
Maybe it is better to resize to targetResolution directly or use the round function instead of int().
The text was updated successfully, but these errors were encountered: