refactor all control processors to support unload and offload

This commit is contained in:
Vladimir Mandic
2024-01-25 11:45:47 -05:00
parent c19f95141a
commit 7aa6876759
27 changed files with 154 additions and 350 deletions
-5
View File
@@ -34,13 +34,11 @@ class EdgeDetector:
input_image = kwargs.pop("img")
if input_image is None:
raise ValueError("input_image must be defined.")
if not isinstance(input_image, np.ndarray):
input_image = np.array(input_image, dtype=np.uint8)
output_type = output_type or "pil"
else:
output_type = output_type or "np"
input_image = HWC3(input_image)
input_image = resize_image(input_image, detect_resolution)
img_gray = cv2.cvtColor(input_image, cv2.COLOR_BGR2GRAY)
@@ -52,12 +50,9 @@ class EdgeDetector:
edge_map = np.expand_dims(edge_map, axis=2)
edge_map = cv2.cvtColor(edge_map, cv2.COLOR_GRAY2BGR).astype(np.uint8)
edge_map = HWC3(edge_map)
img = resize_image(input_image, image_resolution)
H, W, _C = img.shape
edge_map = cv2.resize(edge_map, (W, H), interpolation=cv2.INTER_LINEAR)
if output_type == "pil":
edge_map = Image.fromarray(edge_map)
return edge_map