MCPcopy Index your code
hub / github.com/Stability-AI/generative-models / load_img

Function load_img

scripts/demo/sampling.py:94–109  ·  view source on GitHub ↗
(display=True, key=None, device="cuda")

Source from the content-addressed store, hash-verified

92
93
94def load_img(display=True, key=None, device="cuda"):
95 image = get_interactive_image(key=key)
96 if image is None:
97 return None
98 if display:
99 st.image(image)
100 w, h = image.size
101 print(f"loaded input image of size ({w}, {h})")
102 width, height = map(
103 lambda x: x - x % 64, (w, h)
104 ) # resize to integer multiple of 64
105 image = image.resize((width, height))
106 image = np.array(image.convert("RGB"))
107 image = image[None].transpose(0, 3, 1, 2)
108 image = torch.from_numpy(image).to(dtype=torch.float32) / 127.5 - 1.0
109 return image.to(device)
110
111
112def run_txt2img(

Callers 1

run_img2imgFunction · 0.70

Calls 1

get_interactive_imageFunction · 0.85

Tested by

no test coverage detected