python ndimage_Python ndimage.zoom方法代码示例
本文整理汇总了Python中scipy.ndimage.zoom方法的典型用法代码示例。如果您正苦于以下问题:Python ndimage.zoom方法的具体用法?Python ndimage.zoom怎么用?Python ndimage.zoom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块scipy.ndimage的用法示例。
在下文中一共展示了ndimage.zoom方法的25个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: predict_multiscale
点赞 6
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import zoom [as 别名]
def predict_multiscale(net, image, tile_size, scales, classes, flip_evaluation, recurrence):
"""
Predict an image by looking at it with different scales.
We choose the "predict_whole_img" for the image with less than the original input size,
for the input of larger size, we would choose the cropping method to ensure that GPU memory is enough.
"""
image = image.data
N_, C_, H_, W_ = image.shape
full_probs = np.zeros((H_, W_, classes))
for scale in scales:
scale = float(scale)
print("Predicting image scaled by %f" % scale)
scale_image = ndimage.zoom(image, (1.0, 1.0, scale, scale), order=1, prefilter=False)
scaled_probs = predict_whole(net, scale_image, tile_size, recurrence)
if flip_evaluation == True:
flip_scaled_probs = predict_whole(net, scale_image[:,:,:,::-1].copy(), tile_size, recurrence)
scaled_probs = 0.5 * (scaled_probs + flip_scaled_probs[:,::-1,:])
full_probs += scaled_probs
full_probs /= len(scales)
return full_probs
开发者ID:speedinghzl,项目名称:pytorch-segmentation-toolbox,代码行数:22,
示例2: predict_multiscale
点赞 6
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import zoom [as 别名]
def predict_multiscale(net, image, tile_size, scales, classes, flip_evaluation):
"""
Predict an image by looking at it with different scales.
We choose the "predict_whole_img" for the image with less than the original input size,
for the input of larger size, we would choose the cropping method to ensure that GPU memory is enough.
"""
image = image.data
N_, C_, H_, W_ = image.shape
full_probs = np.zeros((H_, W_, classes))
for scale in scales:
scale = float(scale)
print("Predicting image scaled by %f" % scale)
scale_image = ndimage.zoom(image, (1.0, 1.0, scale, scale), order=1, prefilter=False)
scaled_probs = predict_whole(net, scale_image, tile_size)
if flip_evaluation == True:
flip_scaled_probs = predict_whole(net, scale_image[:, :, :, ::-1].copy(), tile_size)
scaled_probs = 0.5 * (scaled_probs + flip_scaled_probs[:, ::-1, :])
full_probs += scaled_probs
full_probs /= len(scales)
return full_probs
开发者ID:lxtGH,项目名称:Fast_Seg,代码行数:22,
示例3: clipped_zoom
点赞 6
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import zoom [as 别名]
def clipped_zoom(img, zoom_factor):
h = img.shape[0]
# ceil crop height(= crop width)
ch = int(np.ceil(h / zoom_factor))
top = (h - ch) // 2
img = scizoom(img[top:top + ch, top:top + ch], (zoom_factor, zoom_factor, 1), order=1)
# trim off any extra pixels
trim_top = (img.shape[0] - h) // 2
return img[trim_top:trim_top + h, trim_top:trim_top + h]
# /// End Distortion Helpers ///
# /// Distortions ///
开发者ID:hendrycks,项目名称:robustness,代码行数:19,
示例4: generate
点赞 6
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import zoom [as 别名]
def generate(values, nb_classes, batch_size, input_size, image_dir, anno_dir):
while 1:
random.shuffle(values)
images, labels = update_inputs(batch_size=batch_size,
input_size=input_size, num_classes=nb_classes)
for i, d in enumerate(values):
img = imresize(imread(os.path.join(image_dir, d['image']), mode='RGB'), input_size)
y = imread(os.path.join(anno_dir, d['anno']), mode='L')
h, w = input_size
y = zoom(y, (1.*h/y.shape[0], 1.*w/y.shape[1]), order=1, prefilter=False)
y = (np.arange(nb_classes) == y[:,:,None]).astype('float32')
assert y.shape[2] == nb_classes
images[i % batch_size] = img
labels[i % batch_size] = y
if (i + 1) % batch_size == 0:
yield images, labels
images, labels = update_inputs(batch_size=batch_size,
input_size=input_size, num_classes=nb_classes)
开发者ID:Vladkryvoruchko,项目名称:PSPNet-Keras-tensorflow,代码行数:20,
示例5: predict_multi_scale
点赞 6
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import zoom [as 别名]
def predict_multi_scale(full_image, net, scales, sliding_evaluation, flip_evaluation):
"""Predict an image by looking at it with different scales."""
classes = net.model.outputs[0].shape[3]
full_probs = np.zeros((full_image.shape[0], full_image.shape[1], classes))
h_ori, w_ori = full_image.shape[:2]
for scale in scales:
print("Predicting image scaled by %f" % scale)
scaled_img = misc.imresize(full_image, size=scale, interp="bilinear")
if sliding_evaluation:
scaled_probs = predict_sliding(scaled_img, net, flip_evaluation)
else:
scaled_probs = net.predict(scaled_img, flip_evaluation)
# scale probs up to full size
h, w = scaled_probs.shape[:2]
probs = ndimage.zoom(scaled_probs, (1.*h_ori/h, 1.*w_ori/w, 1.),order=1, prefilter=False)
# visualize_prediction(probs)
# integrate probs over all scales
full_probs += probs
full_probs /= len(scales)
return full_probs
开发者ID:Vladkryvoruchko,项目名称:PSPNet-Keras-tensorflow,代码行数:22,
示例6: test_correct_results
点赞 6
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import zoom [as 别名]
def test_correct_results(self, min_zoom, max_zoom, mode, align_corners, keep_size):
key = "img"
random_zoom = RandZoomd(
key,
prob=1.0,
min_zoom=min_zoom,
max_zoom=max_zoom,
mode=mode,
align_corners=align_corners,
keep_size=keep_size,
)
random_zoom.set_random_state(1234)
zoomed = random_zoom({key: self.imt[0]})
expected = list()
for channel in self.imt[0]:
expected.append(zoom_scipy(channel, zoom=random_zoom._zoom, mode="nearest", order=0, prefilter=False))
expected = np.stack(expected).astype(np.float32)
np.testing.assert_allclose(expected, zoomed[key], atol=1.0)
开发者ID:Project-MONAI,项目名称:MONAI,代码行数:21,
示例7: zoom
点赞 6
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import zoom [as 别名]
def zoom(x: np.ndarray, scale_factor: AxesParams, axes: AxesLike = None, order: int = 1,
fill_value: Union[float, Callable] = 0) -> np.ndarray:
"""
Rescale ``x`` according to ``scale_factor`` along the ``axes``.
Parameters
----------
x
scale_factor
axes
axes along which the tensor will be scaled. If None - the last ``len(shape)`` axes are used.
order
order of interpolation.
fill_value
value to fill past edges. If Callable (e.g. `numpy.min`) - ``fill_value(x)`` will be used.
"""
scale_factor = fill_by_indices(np.ones(x.ndim, 'float64'), scale_factor, axes)
if callable(fill_value):
fill_value = fill_value(x)
# remove an annoying warning
with warnings.catch_warnings():
warnings.simplefilter('ignore', UserWarning)
return ndimage.zoom(x, scale_factor, order=order, cval=fill_value)
开发者ID:neuro-ml,项目名称:deep_pipe,代码行数:26,
示例8: zoom_to_shape
点赞 6
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import zoom [as 别名]
def zoom_to_shape(x: np.ndarray, shape: AxesLike, axes: AxesLike = None, order: int = 1,
fill_value: Union[float, Callable] = 0) -> np.ndarray:
"""
Rescale ``x`` to match ``shape`` along the ``axes``.
Parameters
----------
x
shape
final shape.
axes
axes along which the tensor will be scaled. If None - the last ``len(shape)`` axes are used.
order
order of interpolation.
fill_value
value to fill past edges. If Callable (e.g. `numpy.min`) - ``fill_value(x)`` will be used.
"""
old_shape = np.array(x.shape, 'float64')
new_shape = np.array(fill_by_indices(x.shape, shape, axes), 'float64')
return zoom(x, new_shape / old_shape, order=order, fill_value=fill_value)
开发者ID:neuro-ml,项目名称:deep_pipe,代码行数:22,
示例9: proportional_zoom_to_shape
点赞 6
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import zoom [as 别名]
def proportional_zoom_to_shape(x: np.ndarray, shape: AxesLike, axes: AxesLike = None,
padding_values: Union[AxesParams, Callable] = 0, order: int = 1) -> np.ndarray:
"""
Proportionally rescale ``x`` to fit ``shape`` along ``axes`` then pad it to that shape.
Parameters
----------
x
shape
final shape.
axes
axes along which ``x`` will be padded. If None - the last ``len(shape)`` axes are used.
padding_values
values to pad with.
order
order of interpolation.
"""
axes = expand_axes(axes, shape)
scale_factor = (np.array(shape, 'float64') / extract(x.shape, axes)).min()
return pad_to_shape(zoom(x, scale_factor, axes, order), shape, axes, padding_values)
开发者ID:neuro-ml,项目名称:deep_pipe,代码行数:22,
示例10: image_dataset_phase_2
点赞 6
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import zoom [as 别名]
def image_dataset_phase_2(repository, image_number, x, y, feature_offsets, R_offsets, delta):
img = makesize(snd.zoom(readimage(repository, image_number), delta), 1)
(h, w) = img.shape
mask = np.ones((h, w), 'bool')
mask[:, 0] = 0
mask[0, :] = 0
mask[h - 1, :] = 0
mask[:, w - 1] = 0
(nroff, blc) = R_offsets.shape
h -= 2
w -= 2
x += 1
y += 1
rep = np.zeros((nroff, 2))
number = image_number
xs = (x + R_offsets[:, 0]).astype('int')
ys = (y + R_offsets[:, 1]).astype('int')
rep[:, 0] = R_offsets[:, 0]
rep[:, 1] = R_offsets[:, 1]
dataset = dataset_from_coordinates(img, xs, ys, feature_offsets)
return dataset, rep, number
开发者ID:cytomine,项目名称:Cytomine-python-datamining,代码行数:23,
示例11: agregation_phase_2
点赞 6
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import zoom [as 别名]
def agregation_phase_2(repository, image_number, ip, probability_maps, reg, delta, feature_offsets, filter_size, beta, n_iterations):
img = makesize(snd.zoom(readimage(repository, image_number), delta), 1)
(h, w, nldms) = probability_maps.shape
nldms -= 1
mh = h - 1
mw = w - 1
for iteration in range(n_iterations):
y, x = np.where(probability_maps[:, :, ip] >= beta * np.max(probability_maps[:, :, ip]))
dataset = dataset_from_coordinates(img, x + 1, y + 1, feature_offsets)
offsets = reg.predict(dataset)
n_x = (x - offsets[:, 0]).clip(min=0, max=mw)
n_y = (y - offsets[:, 1]).clip(min=0, max=mh)
new_pmap = np.zeros((h, w))
for i in range(n_x.size):
new_pmap[n_y[i], n_x[i]] += probability_maps[y[i], x[i], ip]
probability_maps[:, :, ip] = new_pmap
probability_maps[0, :, ip] = 0
probability_maps[:, 0, ip] = 0
probability_maps[mh, :, ip] = 0
probability_maps[:, mw, ip] = 0
return filter_perso(probability_maps[:, :, ip], filter_size)
开发者ID:cytomine,项目名称:Cytomine-python-datamining,代码行数:24,
示例12: test_uint64_max
点赞 6
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import zoom [as 别名]
def test_uint64_max():
# Test interpolation respects uint64 max. Reported to fail at least on
# win32 (due to the 32 bit visual C compiler using signed int64 when
# converting between uint64 to double) and Debian on s390x.
# Interpolation is always done in double precision floating point, so we
# use the largest uint64 value for which int(float(big)) still fits in
# a uint64.
big = 2**64-1025
arr = np.array([big, big, big], dtype=np.uint64)
# Tests geometric transform (map_coordinates, affine_transform)
inds = np.indices(arr.shape) - 0.1
x = ndimage.map_coordinates(arr, inds)
assert_equal(x[1], int(float(big)))
assert_equal(x[2], int(float(big)))
# Tests zoom / shift
x = ndimage.shift(arr, 0.1)
assert_equal(x[1], int(float(big)))
assert_equal(x[2], int(float(big)))
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:20,
示例13: deep_dream
点赞 6
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import zoom [as 别名]
def deep_dream(image, model, iterations, lr, octave_scale, num_octaves):
""" Main deep dream method """
image = preprocess(image).unsqueeze(0).cpu().data.numpy()
# Extract image representations for each octave
octaves = [image]
for _ in range(num_octaves - 1):
octaves.append(nd.zoom(octaves[-1], (1, 1, 1 / octave_scale, 1 / octave_scale), order=1))
detail = np.zeros_like(octaves[-1])
for octave, octave_base in enumerate(tqdm.tqdm(octaves[::-1], desc="Dreaming")):
if octave > 0:
# Upsample detail to new octave dimension
detail = nd.zoom(detail, np.array(octave_base.shape) / np.array(detail.shape), order=1)
# Add deep dream detail from previous octave to new base
input_image = octave_base + detail
# Get new deep dream image
dreamed_image = dream(input_image, model, iterations, lr)
# Extract deep dream details
detail = dreamed_image - octave_base
return deprocess(dreamed_image)
开发者ID:eriklindernoren,项目名称:PyTorch-Deep-Dream,代码行数:24,
示例14: _clipped_zoom_no_scipy_warning
点赞 6
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import zoom [as 别名]
def _clipped_zoom_no_scipy_warning(img, zoom_factor):
from scipy.ndimage import zoom as scizoom
with warnings.catch_warnings():
warnings.filterwarnings("ignore", ".*output shape of zoom.*")
# clipping along the width dimension:
ch0 = int(np.ceil(img.shape[0] / float(zoom_factor)))
top0 = (img.shape[0] - ch0) // 2
# clipping along the height dimension:
ch1 = int(np.ceil(img.shape[1] / float(zoom_factor)))
top1 = (img.shape[1] - ch1) // 2
img = scizoom(img[top0:top0 + ch0, top1:top1 + ch1],
(zoom_factor, zoom_factor, 1), order=1)
return img
开发者ID:aleju,项目名称:imgaug,代码行数:20,
示例15: im_rescale
点赞 6
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import zoom [as 别名]
def im_rescale(img, scale_factor):
zoomed_img = np.zeros_like(img, dtype=img.dtype)
zoomed = skimage.transform.rescale(img, scale_factor)
if scale_factor >= 1.0:
shift_x = (zoomed.shape[0] - img.shape[0]) // 2
shift_y = (zoomed.shape[1] - img.shape[1]) // 2
zoomed_img[:,:] = zoomed[shift_x:shift_x+img.shape[0], shift_y:shift_y+img.shape[1]]
else:
shift_x = (img.shape[0] - zoomed.shape[0]) // 2
shift_y = (img.shape[1] - zoomed.shape[1]) // 2
zoomed_img[shift_x:shift_x+zoomed.shape[0], shift_y:shift_y+zoomed.shape[1]] = zoomed
return zoomed_img
# this old version uses ndimage zoom which is unreliable
开发者ID:benanne,项目名称:kaggle-galaxies,代码行数:19,
示例16: im_rescale_old
点赞 6
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import zoom [as 别名]
def im_rescale_old(img, scale_factor):
zoomed_img = np.zeros_like(img, dtype=img.dtype)
if img.ndim == 2:
z = (scale_factor, scale_factor)
elif img.ndim == 3:
z = (scale_factor, scale_factor, 1)
# else fail
zoomed = ndimage.zoom(img, z)
if scale_factor >= 1.0:
shift_x = (zoomed.shape[0] - img.shape[0]) // 2
shift_y = (zoomed.shape[1] - img.shape[1]) // 2
zoomed_img[:,:] = zoomed[shift_x:shift_x+img.shape[0], shift_y:shift_y+img.shape[1]]
else:
shift_x = (img.shape[0] - zoomed.shape[0]) // 2
shift_y = (img.shape[1] - zoomed.shape[1]) // 2
zoomed_img[shift_x:shift_x+zoomed.shape[0], shift_y:shift_y+zoomed.shape[1]] = zoomed
return zoomed_img
开发者ID:benanne,项目名称:kaggle-galaxies,代码行数:22,
示例17: render
点赞 6
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import zoom [as 别名]
def render(self, mode='human', close=False):
if close:
if self.viewer is not None:
self.viewer.close()
self.viewer = None
img = self.get_obs()[0]
if mode == 'rgb_array':
return img
elif mode == 'human':
from gym.envs.classic_control import rendering
from scipy.ndimage import zoom
if self.viewer is None:
self.viewer = rendering.SimpleImageViewer()
img = zoom(img, [5, 5, 1], order=0)
self.viewer.imshow(img)
else:
raise NotImplementedError
# Generate ground truth Q-frames by finding the smallest number of steps towards all coordinates given a window position.
开发者ID:fabiopardo,项目名称:qmap,代码行数:21,
示例18: handleBands
点赞 6
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import zoom [as 别名]
def handleBands(data, snapshape):
import numpy as np
from scipy.ndimage import zoom
try:
data[np.where(data.mask == True)] = data.min()
except AttributeError:
pass
if data.shape != snapshape:
data = handleArrays(data)
data = zoom(data, 2 * snapshape[1] / data.shape[1], order=1)
data = ((np.roll(data, 1, axis=0) + data) / 2)[1:]
else:
data = handleArrays(data)
return data
开发者ID:mapbox,项目名称:grib-doctor,代码行数:18,
示例19: _log_density
点赞 6
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import zoom [as 别名]
def _log_density(self, stimulus):
smap = self.parent_model.log_density(stimulus)
target_shape = (stimulus.shape[0],
stimulus.shape[1])
if smap.shape != target_shape:
if self.verbose:
print("Resizing saliency map", smap.shape, target_shape)
x_factor = target_shape[1] / smap.shape[1]
y_factor = target_shape[0] / smap.shape[0]
smap = zoom(smap, [y_factor, x_factor], order=1, mode='nearest')
smap -= logsumexp(smap)
assert smap.shape == target_shape
return smap
开发者ID:matthias-k,项目名称:pysaliency,代码行数:21,
示例20: conditional_log_density
点赞 6
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import zoom [as 别名]
def conditional_log_density(self, stimulus, x_hist, y_hist, t_hist, attributes=None, out=None):
smap = self.parent_model.conditional_log_density(stimulus, x_hist, y_hist, t_hist, attributes=attributes, out=out)
target_shape = (stimulus.shape[0],
stimulus.shape[1])
if smap.shape != target_shape:
if self.verbose:
print("Resizing saliency map", smap.shape, target_shape)
x_factor = target_shape[1] / smap.shape[1]
y_factor = target_shape[0] / smap.shape[0]
smap = zoom(smap, [y_factor, x_factor], order=1, mode='nearest')
smap -= logsumexp(smap)
assert smap.shape == target_shape
return smap
开发者ID:matthias-k,项目名称:pysaliency,代码行数:21,
示例21: _saliency_map
点赞 6
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import zoom [as 别名]
def _saliency_map(self, stimulus):
smap = self.parent_model.saliency_map(stimulus)
target_shape = (stimulus.shape[0],
stimulus.shape[1])
if smap.shape != target_shape:
if self.verbose:
print("Resizing saliency map", smap.shape, target_shape)
x_factor = target_shape[1] / smap.shape[1]
y_factor = target_shape[0] / smap.shape[0]
smap = zoom(smap, [y_factor, x_factor], order=1, mode='nearest')
assert smap.shape == target_shape
return smap
开发者ID:matthias-k,项目名称:pysaliency,代码行数:19,
示例22: clipped_zoom
点赞 6
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import zoom [as 别名]
def clipped_zoom(x: np.ndarray, zoom_factor: float) -> np.ndarray:
"""
Helper function for zoom blur.
Parameters
----------
x
Instance to be perturbed.
zoom_factor
Zoom strength.
Returns
-------
Cropped and zoomed instance.
"""
h = x.shape[0]
ch = int(np.ceil(h / float(zoom_factor))) # ceil crop height(= crop width)
top = (h - ch) // 2
x = zoom(x[top:top + ch, top:top + ch], (zoom_factor, zoom_factor, 1), order=1)
trim_top = (x.shape[0] - h) // 2 # trim off any extra pixels
return x[trim_top:trim_top + h, trim_top:trim_top + h]
开发者ID:SeldonIO,项目名称:alibi-detect,代码行数:23,
示例23: multi_scale_predict
点赞 6
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import zoom [as 别名]
def multi_scale_predict(model, image, scales, num_classes, device, flip=False):
input_size = (image.size(2), image.size(3))
upsample = nn.Upsample(size=input_size, mode='bilinear', align_corners=True)
total_predictions = np.zeros((num_classes, image.size(2), image.size(3)))
image = image.data.data.cpu().numpy()
for scale in scales:
scaled_img = ndimage.zoom(image, (1.0, 1.0, float(scale), float(scale)), order=1, prefilter=False)
scaled_img = torch.from_numpy(scaled_img).to(device)
scaled_prediction = upsample(model(scaled_img).cpu())
if flip:
fliped_img = scaled_img.flip(-1).to(device)
fliped_predictions = upsample(model(fliped_img).cpu())
scaled_prediction = 0.5 * (fliped_predictions.flip(-1) + scaled_prediction)
total_predictions += scaled_prediction.data.cpu().numpy().squeeze(0)
total_predictions /= len(scales)
return total_predictions
开发者ID:yassouali,项目名称:pytorch_segmentation,代码行数:21,
示例24: zoom_image
点赞 6
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import zoom [as 别名]
def zoom_image(img, source_rect, target_shape=None):
"""Zooms pixels from the source_rect of img to target_shape."""
import warnings
from scipy.ndimage import zoom
if target_shape is None:
target_shape = img.shape
st, sb, sl, sr = source_rect
source = img[st:sb, sl:sr]
if source.shape == target_shape:
return source
zoom_tuple = tuple(float(t) / s
for t, s in zip(target_shape, source.shape[:2])
) + (1,) * (img.ndim - 2)
with warnings.catch_warnings():
warnings.simplefilter('ignore', UserWarning) # "output shape of zoom"
target = zoom(source, zoom_tuple)
assert target.shape[:2] == target_shape, (target.shape, target_shape)
return target
开发者ID:CSAILVision,项目名称:gandissect,代码行数:20,
示例25: predict_whole_img_
点赞 5
# 需要导入模块: from scipy import ndimage [as 别名]
# 或者: from scipy.ndimage import zoom [as 别名]
def predict_whole_img_(net, image, scale):
"""
Parameters
----------
net : nn.Module
image : torch.Tensor
shape [batch_size, c, h, w]
scale : scalar
Return
------
full_probs : numpy.ndarray
shape [batch_size, classes, h, w]
Description
-----------
Predict the whole image w/o using multiple crops.
The scale specify whether rescale the input image before predicting the results.
"""
#image = image.cpu().numpy()
_, _, H_, W_ = image.shape
if scale != 1:
#scaled_img = ndimage.zoom(image, (1.0, 1.0, scale, scale), order=1, prefilter=False)
scaled_img = F.interpolate(image, scale_factor=scale, mode='bilinear', align_corners=True)
else:
scaled_img = image
full_probs_ = net(scaled_img)
if isinstance(full_probs_, list):
full_probs = full_probs_[-1]
else:
full_probs = full_probs_
full_depths = net.inference(full_probs) * scale
full_depths = F.interpolate(full_depths, size=(H_, W_), mode='nearest')
return full_depths
开发者ID:miraiaroha,项目名称:ACAN,代码行数:36,
注:本文中的scipy.ndimage.zoom方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。
python ndimage_Python ndimage.zoom方法代码示例相关推荐
- python dateformatter_Python dates.DateFormatter方法代码示例
本文整理汇总了Python中matplotlib.dates.DateFormatter方法的典型用法代码示例.如果您正苦于以下问题:Python dates.DateFormatter方法的具体用法 ...
- python paperclip_Python pyplot.sca方法代码示例
本文整理汇总了Python中matplotlib.pyplot.sca方法的典型用法代码示例.如果您正苦于以下问题:Python pyplot.sca方法的具体用法?Python pyplot.sca ...
- python fonttool_Python wx.Font方法代码示例
本文整理汇总了Python中wx.Font方法的典型用法代码示例.如果您正苦于以下问题:Python wx.Font方法的具体用法?Python wx.Font怎么用?Python wx.Font使用 ...
- python res_Python models.resnet152方法代码示例
本文整理汇总了Python中torchvision.models.resnet152方法的典型用法代码示例.如果您正苦于以下问题:Python models.resnet152方法的具体用法?Pyth ...
- python dropout_Python slim.dropout方法代码示例
本文整理汇总了Python中tensorflow.contrib.slim.dropout方法的典型用法代码示例.如果您正苦于以下问题:Python slim.dropout方法的具体用法?Pytho ...
- python batch_size_Python config.batch_size方法代码示例
本文整理汇总了Python中config.batch_size方法的典型用法代码示例.如果您正苦于以下问题:Python config.batch_size方法的具体用法?Python config. ...
- python pool_Python pool.Pool方法代码示例
本文整理汇总了Python中multiprocessing.pool.Pool方法的典型用法代码示例.如果您正苦于以下问题:Python pool.Pool方法的具体用法?Python pool.Po ...
- python nextpow2_Python signal.hann方法代码示例
本文整理汇总了Python中scipy.signal.hann方法的典型用法代码示例.如果您正苦于以下问题:Python signal.hann方法的具体用法?Python signal.hann怎么 ...
- python colormap_Python colors.LinearSegmentedColormap方法代码示例
本文整理汇总了Python中matplotlib.colors.LinearSegmentedColormap方法的典型用法代码示例.如果您正苦于以下问题:Python colors.LinearSe ...
- python transformat_Python transforms.Bbox方法代码示例
本文整理汇总了Python中matplotlib.transforms.Bbox方法的典型用法代码示例.如果您正苦于以下问题:Python transforms.Bbox方法的具体用法?Python ...
最新文章
- 深度整合英特尔傲腾,SmartX首发100us级超低延迟超融合解决方案
- 利用Pytorch的C++前端(libtorch)读取预训练权重并进行预测
- 基于财通证券的数字化建设,总结的金融行业数字化转型方向
- 外网访问FTP服务,解决只能以POST模式访问Filezilla的问题
- 1019. 链表中的下一个更大节点
- linux一次执行多个命令,linux 一次执行多条命令
- OSPF算法详细说明
- OpenCV-PS扩散效果(毛玻璃)
- 引入ELK前需要知道的“坑”(上)
- 首届魔都ArchData技术峰会进入倒计时
- could not resolve property: qid of: org.lxh.myzngt.vo.Answer
- 如何正确安装独立显卡?图文详解教会你安装独立显卡
- OpenCV开发笔记(六十七):红胖子8分钟带你深入了解特征点暴力匹配(图文并茂+浅显易懂+程序源码)
- 教你在MathType中输入空心字和花体字的重要方法
- U盘和存储卡实际上可以轻松的创建隐藏分区制作PE启动盘
- diy 扫地机器人 滚刷_扫地机器人滚刷和边刷分别有什么作用
- 后端接口并行调用方案
- [No0000C8]英特尔快速存储IRST要不要装
- 西南交通大学算法与设计实验1.3
- Superset-轻量级开源可视化BI工具
热门文章
- 我对javascript面向对象编程的理解---------继承
- 为SAP列表设置新的打印格式
- java struts 读取文件_读取文件.txt并将其保存到c中的struct
- 关于springboot与freeMarker的使用
- 群之脉PHP面试,面试问Redis集群,被虐的不行了......
- html前端订餐网页代码_21天学通HTML+CSS+JavaScript Web开发 中文完整PDF版
- 少年时期最后一个儿童节
- linux快速安装mysql教程
- js中数组的一些常见操作 - 1
- 笔记本搜不到寝室路由的无线信号怎么办