ACCC1380 commited on
Commit
cf0ba61
1 Parent(s): c51edd7

Upload lora-scripts/sd-scripts/tools/canny.py with huggingface_hub

Browse files
lora-scripts/sd-scripts/tools/canny.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse
2
+ import cv2
3
+
4
+ import logging
5
+ from library.utils import setup_logging
6
+ setup_logging()
7
+ logger = logging.getLogger(__name__)
8
+
9
+ def canny(args):
10
+ img = cv2.imread(args.input)
11
+ img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
12
+
13
+ canny_img = cv2.Canny(img, args.thres1, args.thres2)
14
+ # canny_img = 255 - canny_img
15
+
16
+ cv2.imwrite(args.output, canny_img)
17
+ logger.info("done!")
18
+
19
+
20
+ def setup_parser() -> argparse.ArgumentParser:
21
+ parser = argparse.ArgumentParser()
22
+ parser.add_argument("--input", type=str, default=None, help="input path")
23
+ parser.add_argument("--output", type=str, default=None, help="output path")
24
+ parser.add_argument("--thres1", type=int, default=32, help="thres1")
25
+ parser.add_argument("--thres2", type=int, default=224, help="thres2")
26
+
27
+ return parser
28
+
29
+
30
+ if __name__ == '__main__':
31
+ parser = setup_parser()
32
+
33
+ args = parser.parse_args()
34
+ canny(args)