Golbstein / Keras-segmentation-deeplab-v3.1

An awesome semantic segmentation model that runs in real time
175 stars 73 forks source link

predict #19

Closed swjtulinxi closed 4 years ago

swjtulinxi commented 4 years ago

can you send us a predict.py,because you mode don't contain a predict.py,so we can't use it to predict

Mps24-7uk commented 3 years ago

import matplotlib.pyplot as plt import numpy as np from ut_ import * import os import cv2

os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID" os.environ["CUDA_VISIBLE_DEVICES"] = "1"

image_size = (720, 1024) #(512,512) (720, 1280) x = cv2.imread("9acec1f912673a1364dd776355b707ce-44684.jpg") x = cv2.resize(x,image_size[::-1]) x = x.reshape(-1,x.shape[0],x.shape[1],x.shape[2])

n_classes = len(get_VOC2012_classes()) - 1

SegClass = SegModel(None, image_size)

model1 = SegClass.create_seg_model(net='subpixel',n=n_classes, load_weights=False, multi_gpu=False, backbone='xception') model1.load_weights('weights/xception_subpixel.h5')

preds1 = np.argmax(model1.predict(x), -1)[0].reshape(image_size)

plt.figure(figsize=(14,10)) plt.subplot(141) plt.imshow(preds1) plt.axis('off'); plt.savefig("test.png", dpi=200, bbox_inches='tight')