guohp123456 commited on
Commit
a9d7745
·
verified ·
1 Parent(s): 70ce2d5

Create utils.py

Browse files
Files changed (1) hide show
  1. utils.py +10 -0
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)