Download src/backend/annotators/canny_control.py from clone3/FastGUI: direct link, hf CLI and curl.
- Browser
- Download file 523 Bytes
-
https://huggingface.co/spaces/clone3/FastGUI/resolve/main/src/backend/annotators/canny_control.py
- Command line
-
hf download hf://spaces/clone3/FastGUI/src/backend/annotators/canny_control.py
-
curl -L -o canny_control.py https://huggingface.co/spaces/clone3/FastGUI/resolve/main/src/backend/annotators/canny_control.py
523 Bytes
| import numpy as np | |
| from backend.annotators.control_interface import ControlInterface | |
| from cv2 import Canny | |
| from PIL import Image | |
| class CannyControl(ControlInterface): | |
| def get_control_image(self, image: Image) -> Image: | |
| low_threshold = 100 | |
| high_threshold = 200 | |
| image = np.array(image) | |
| image = Canny(image, low_threshold, high_threshold) | |
| image = image[:, :, None] | |
| image = np.concatenate([image, image, image], axis=2) | |
| return Image.fromarray(image) | |