MCPcopy Create free account
hub / github.com/thygate/stable-diffusion-webui-depthmap-script / url_to_torch

Function url_to_torch

dzoedepth/utils/misc.py:347–353  ·  view source on GitHub ↗
(url, size=(384, 384))

Source from the content-addressed store, hash-verified

345 return img
346
347def url_to_torch(url, size=(384, 384)):
348 img = get_image_from_url(url)
349 img = img.resize(size, Image.ANTIALIAS)
350 img = torch.from_numpy(np.asarray(img)).float()
351 img = img.permute(2, 0, 1)
352 img.div_(255)
353 return img
354
355def pil_to_batched_tensor(img):
356 return ToTensor()(img).unsqueeze(0)

Callers

nothing calls this directly

Calls 1

get_image_from_urlFunction · 0.85

Tested by

no test coverage detected