-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrun.py
27 lines (20 loc) · 862 Bytes
/
run.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
import keras_segmentation
import os
images_path = "./Datasets/CUB_200_2011/images/"
segs_path = "./Datasets/CUB_200_2011/converted/"
model = keras_segmentation.models.unet.vgg_unet(n_classes=2 , input_height=416, input_width=608 )
model.train(
train_images = images_path,
train_annotations = segs_path,
checkpoints_path = "/tmp/vgg_unet_1" , epochs=5
)
out = model.predict_segmentation(
inp= os.path.join(images_path, "001.Black_footed_Albatross", "Black_Footed_Albatross_0001_796111.jpg"),
out_fname="./tmp/out.png"
)
import matplotlib.pyplot as plt
plt.imshow(out)
model.evaluate_segmentation(
inp_images = [os.path.join(images_path, "001.Black_footed_Albatross", "Black_footed_Albatross_0001_796111.jpg")],
annotations = [os.path.join(segs_path, "001.Black_footed_Albatross", "Black_footed_Albatross_0001_796111.jpg")]
)