Skip to content

Commit e5b96a0

Browse files
Fixed directory not found error
1 parent 74e1783 commit e5b96a0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/MAGIST/Vision/UnsupervisedModels/img_cluster.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,11 @@ def image_to_pandas(image):
9393
img2[:, :, 1] = img2[:, :, 1]*(result==[n]) # Disabling pixels of certain type
9494
img2[:, :, 2] = img2[:, :, 2]*(result==[n]) # Disabling pixels of certain type
9595
unit_img = img_as_ubyte(img2)
96-
imsave(f'{masked_img_dir}/masked{n}.jpg', unit_img)
96+
try:
97+
imsave(f'{masked_img_dir}/masked{n}.jpg', unit_img)
98+
except FileNotFoundError:
99+
pathlib.Path(masked_img_dir).mkdir(parents=True, exist_ok=True)
100+
imsave(f'{masked_img_dir}/masked{n}.jpg', unit_img)
97101
clustered_img.append(f'{masked_img_dir}/masked{n}.jpg')
98102
ax.imshow(img2);
99103
ax.set_axis_off()

0 commit comments

Comments
 (0)