-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprediction.py
21 lines (16 loc) · 870 Bytes
/
prediction.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import pixellib
import matplotlib.pyplot as plt
from pixellib.semantic import semantic_segmentation
DATA_URL = "deeplabv3_xception_tf_dim_ordering_tf_kernels.h5"
def prediction(img_file):
# instantiating the semantic segmentation class
segment_image = semantic_segmentation()
# loading the model deeplabv3+ trained on pascal voc dataset.
segment_image.load_pascalvoc_model(DATA_URL)
# performing the segmentation on the input image
segment_image.segmentAsPascalvoc(img_file, output_image_name = "output_images/out.jpg")
out = plt.imread("output_images/out.jpg", 0)
# performing the segmentation on the input image with overlay
segment_image.segmentAsPascalvoc(img_file, output_image_name = "output_images/out_overlay.jpg", overlay = True)
out_overlay = plt.imread("output_images/out_overlay.jpg")
return out, out_overlay