MCPcopy Create free account
hub / github.com/YesianRohn/TextSSR / preprocess

Function preprocess

diffusers/examples/community/imagic_stable_diffusion.py:51–58  ·  view source on GitHub ↗
(image)

Source from the content-addressed store, hash-verified

49
50
51def preprocess(image):
52 w, h = image.size
53 w, h = (x - x % 32 for x in (w, h)) # resize to integer multiple of 32
54 image = image.resize((w, h), resample=PIL_INTERPOLATION["lanczos"])
55 image = np.array(image).astype(np.float32) / 255.0
56 image = image[None].transpose(0, 3, 1, 2)
57 image = torch.from_numpy(image)
58 return 2.0 * image - 1.0
59
60
61class ImagicStableDiffusionPipeline(DiffusionPipeline, StableDiffusionMixin):

Callers 1

trainMethod · 0.70

Calls 2

transposeMethod · 0.80
resizeMethod · 0.45

Tested by

no test coverage detected