-
Notifications
You must be signed in to change notification settings - Fork 0
/
utilities.py
48 lines (34 loc) · 1.05 KB
/
utilities.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import urllib.request
from PIL import Image
import matplotlib.pyplot as plt
def download_file(url, output_path):
urllib.request.urlretrieve(url, output_path)
def show_img(image_path):
# Open the image file
image = Image.open(image_path)
# Display the image
plt.imshow(image)
plt.axis('off')
plt.show()
def show_all_results(segmented_img,
mask,
diffused_img):
# Create a figure with three subplots
fig, axes = plt.subplots(1, 3, figsize=(10, 5))
# Display the first image
# axes[0].imshow(cv2.cvtColor(segmented_img, cv2.COLOR_BGR2RGB))
axes[0].imshow(segmented_img)
axes[0].axis('off')
axes[0].set_title('input image')
# Display the second image
axes[1].imshow(mask)
axes[1].axis('off')
axes[1].set_title('object segmentation')
# Display the third image
axes[2].imshow(diffused_img)
axes[2].axis('off')
axes[2].set_title('diffused image')
# Adjust the layout
plt.tight_layout()
# Show the figure
plt.show()