mirror of
https://github.com/vladmandic/automatic
synced 2026-09-20 01:31:13 +02:00
refactor all control processors to support unload and offload
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user