Open david-bernstein opened 5 years ago
@david-bernstein ,
I will update demo.ipynb
in recent weeks. Thank you for your advice!
Thanks!
@david-bernstein
You may refer my modify --- a/network.py +++ b/network.py @@ -76,8 +76,13 @@ class Network(object): if data_path.endswith('.npy'): self.load_npy(data_path, self.sess) else:
hi, i use this demo.py modified by the demo.ipynb, it can run and return teh result ,but the result is all wrong。
the code is:
import argparse import tensorflow as tf import numpy as np import cv2 import time import matplotlib.pyplot as plt
from tqdm import trange from utils.config import Config from model import ICNet, ICNet_BN
########【1】Setup configurations model_config = {'train': ICNet, 'trainval': ICNet, 'train_bn': ICNet_BN, 'trainval_bn': ICNet_BN, 'others': ICNet_BN}
dataset = 'others' filter_scale = 1
class InferenceConfig(Config): def init(self, dataset, is_training, filter_scale): Config.init(self, dataset, is_training, filter_scale)
model_type = 'others'
model_weight = '/disk3t-2/zym/tensorflow-ICNet/snapshots/model.ckpt-23000'
INFER_SIZE = (512, 512, 3)
cfg = InferenceConfig(dataset, is_training=False, filter_scale=filter_scale) cfg.display()
########【2】Create graph, session, and restore weights
model = model_config[cfg.model_type] net = model(cfg=cfg, mode='inference')
net.create_session() net.restore(cfg.model_weight)
########【3】Run segmentation on single image im1 = cv2.imread('./data/input/4.jpg')
if im1.shape != cfg.INFER_SIZE: im1 = cv2.resize(im1, (cfg.INFER_SIZE[1], cfg.INFER_SIZE[0]))
results1 = net.predict(im1) overlap_results1 = 0.5 im1 + 0.5 results1[0] vis_im1 = np.concatenate([im1/255.0, results1[0]/255.0, overlap_results1/255.0], axis=1)
plt.figure(figsize=(20, 15))
#######【4】Test inference speed elapsed_times = []
for i in range(50): start_t = time.time()
_ = net.predict(im1)
duration = time.time() - start_t
if i > 0:
elapsed_times.append(duration)
print('Average time: {:.4f}, about {:.6f} fps'.format(np.mean(elapsed_times), 1/np.mean(elapsed_times)))
Hi,@zhangyunming. I have the same problem with you. Have you dealed with it?
Hi,@zhangyunming. I have the same problem with you. Have you dealed with it?
Could you include a cell that shows how to use a checkpoint created by train.py for inference?