Spaces:
Runtime error
Runtime error
Create utils.py
Browse files
utils.py
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import cv2
|
2 |
+
import numpy as np
|
3 |
+
from PIL import Image
|
4 |
+
|
5 |
+
def generate_canny(image: Image.Image, low_threshold=50, high_threshold=150) -> Image.Image:
|
6 |
+
image = image.resize((1024, 1024))
|
7 |
+
img_np = np.array(image)
|
8 |
+
edges = cv2.Canny(img_np, low_threshold, high_threshold)
|
9 |
+
edges_rgb = cv2.cvtColor(edges, cv2.COLOR_GRAY2RGB)
|
10 |
+
return Image.fromarray(edges_rgb)
|