-
Notifications
You must be signed in to change notification settings - Fork 90
Description
What is wrong with my code?
I am using smooth windowing for autoencoder
test_img = cv2.imread("a.jpg")
test_img = cv2.resize(test_img, (768, 1024))
test_img = np.array(test_img)
test_img = test_img.astype('float32')
test_img /= 255
test_img.shape
(1024, 768, 3)
predictions_smooth = predict_img_with_smooth_windowing(
test_img,
window_size=64,
subdivisions=2, # Minimal amount of overlap for windowing. Must be an even number.
nb_classes=3,
pred_func=(
lambda img_batch_subdiv: autoencoder.predict((img_batch_subdiv))
)
)
0%| | 0/8 [00:00<?, ?it/s]
AxisError Traceback (most recent call last)
in ()
5 nb_classes=3,
6 pred_func=(
----> 7 lambda img_batch_subdiv: autoencoder.predict((img_batch_subdiv))
8 )
9 )
5 frames
/content/smooth_tiled_predictions.py in predict_img_with_smooth_windowing(input_img, window_size, subdivisions, nb_classes, pred_func)
251 # possible to fake a full-size window which would in fact just have a narrow
252 # non-zero dommain. This may require to augment the subdivisions
argument
--> 253 # to 4 rather than 2.
254
255 res = []
/content/smooth_tiled_predictions.py in _windowed_subdivs(padded_img, window_size, subdivisions, nb_classes, pred_func)
163 nb_patches_along_Y,
164 patches_resolution_along_X,
--> 165 patches_resolution_along_Y,
166 nb_output_channels
167 )
/content/smooth_tiled_predictions.py in _window_2D(window_size, power)
57 """
58 Make a 1D window function, then infer and return a 2D window function.
---> 59 Done with an augmentation, and self multiplication with its transpose.
60 Could be generalized to more dimensions.
61 """
<array_function internals> in expand_dims(*args, **kwargs)
/usr/local/lib/python3.7/dist-packages/numpy/lib/shape_base.py in expand_dims(a, axis)
595
596 out_ndim = len(axis) + a.ndim
--> 597 axis = normalize_axis_tuple(axis, out_ndim)
598
599 shape_it = iter(a.shape)
/usr/local/lib/python3.7/dist-packages/numpy/core/numeric.py in normalize_axis_tuple(axis, ndim, argname, allow_duplicate)
1356 pass
1357 # Going via an iterator directly is slower than via list comprehension.
-> 1358 axis = tuple([normalize_axis_index(ax, ndim, argname) for ax in axis])
1359 if not allow_duplicate and len(set(axis)) != len(axis):
1360 if argname:
/usr/local/lib/python3.7/dist-packages/numpy/core/numeric.py in (.0)
1356 pass
1357 # Going via an iterator directly is slower than via list comprehension.
-> 1358 axis = tuple([normalize_axis_index(ax, ndim, argname) for ax in axis])
1359 if not allow_duplicate and len(set(axis)) != len(axis):
1360 if argname:
AxisError: axis 3 is out of bounds for array of dimension 2