-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpredict.py
32 lines (25 loc) · 1018 Bytes
/
predict.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
import tensorflow as tf
from Model.Model import SegmentationModel
import Scripts.DataPrepering as dp
from IPython.display import clear_output
import matplotlib.pyplot as plt
import argparse
import numpy as np
from matplotlib import image
from matplotlib import pyplot
from PIL import Image
def main():
parser = argparse.ArgumentParser(description="Semantic segmentation people from image")
requiredArgs = parser.add_argument_group("Required argument")
requiredArgs.add_argument("--input", dest="input", type=str, help="Path to image for segmentation", required=True)
args = parser.parse_args()
model = tf.keras.models.load_model("model_with_augumentation_100e_92_77")
img = Image.open(args.input)
img = img.resize((128,128))
img = np.asarray(img).astype('float32')
print(img.shape)
img = np.reshape(img, (1,128,128,3))
predict = model.predict(img)
return dp.display([img[0], dp.create_mask(predict)])
if __name__ == '__main__':
main()