MCPcopy Create free account
hub / github.com/CiaraStrawberry/TemporalKit / gethedfromsd

Function gethedfromsd

scripts/stable_diffusion_processing.py:133–158  ·  view source on GitHub ↗
(image_path,resolution)

Source from the content-addressed store, hash-verified

131
132# Send the request for hed map from the server based on a filepath
133def gethedfromsd(image_path,resolution):
134 print(resolution)
135 #with open(image_path, "rb") as f:
136 # image = base64.b64encode(f.read()).decode("utf-8")
137 image_smol = utilityb.resize_base64_image(image_path,resolution,resolution)
138 url = "http://127.0.0.1:7860/controlnet/detect"
139 data2 = {
140 "controlnet_module": "hed",
141 "controlnet_input_images": [image_smol],
142 "controlnet_processor_res": resolution,
143 }
144
145 response = requests.post(url, json=data2)
146 if response.status_code == 200:
147 data = response.content
148 loaded = json.loads(data)
149 #print(response.content)
150 encoded_image = loaded["images"][0]
151 #print(f"encoded: {encoded_image}")
152
153 return encoded_image
154 elif response.status_code == 422:
155 error = response.json()
156 print("Validation error:", error)
157 else:
158 print("Unexpected error from hed:", response.status_code, response.text)
159
160
161

Callers 1

prepare_requestFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected