Spaces:
Running
Running
Sagar Bharadwaj
commited on
Commit
·
2b32b36
1
Parent(s):
d2ae102
Create output directory if it doesn't exist
Browse files- ColorByNumber.ipynb +1 -0
- colorbynumber/utils.py +6 -0
ColorByNumber.ipynb
CHANGED
@@ -68,6 +68,7 @@
|
|
68 |
" (255, 255, 255), # White\n",
|
69 |
"]\n",
|
70 |
"\n",
|
|
|
71 |
"config = {\n",
|
72 |
" \"denoise\": True,\n",
|
73 |
" \"denoise_h\": 200,\n",
|
|
|
68 |
" (255, 255, 255), # White\n",
|
69 |
"]\n",
|
70 |
"\n",
|
71 |
+
"# See colorbynumber/config.py for an explanation of these values\n",
|
72 |
"config = {\n",
|
73 |
" \"denoise\": True,\n",
|
74 |
" \"denoise_h\": 200,\n",
|
colorbynumber/utils.py
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
import cv2 as cv
|
2 |
from matplotlib import pyplot as plt
|
3 |
import numpy as np
|
@@ -23,4 +25,8 @@ def draw_contours(contour, image_width, image_height):
|
|
23 |
def save_image(image, filename, convert_to_bgr = True):
|
24 |
if convert_to_bgr:
|
25 |
image = cv.cvtColor(image.astype(np.uint8), cv.COLOR_RGB2BGR)
|
|
|
|
|
|
|
|
|
26 |
cv.imwrite(filename, image)
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
import cv2 as cv
|
4 |
from matplotlib import pyplot as plt
|
5 |
import numpy as np
|
|
|
25 |
def save_image(image, filename, convert_to_bgr = True):
|
26 |
if convert_to_bgr:
|
27 |
image = cv.cvtColor(image.astype(np.uint8), cv.COLOR_RGB2BGR)
|
28 |
+
|
29 |
+
directory = os.path.dirname(filename)
|
30 |
+
if not os.path.exists(directory):
|
31 |
+
os.makedirs(directory)
|
32 |
cv.imwrite(filename, image)
|