2018年5月15日星期二

Yolov2计算自己数据集上anchors

1. 首先生成训练集xml转txt文件:
import os 
import random 
 
trainval_percent = 0.0
train_percent = 1

classes='crazing'
classes='inclusion'
classes='patches'
classes='pitted_surface'
classes='rolled-in_scale'
classes='scratches'

xmlfilepath = '/Users/sisyphus/darkflow/VOC2018/Annotations/'
txtsavepath = '/Users/sisyphus/darkflow/VOC2018/ImageSets/Main/' 
total_xml = os.listdir(xmlfilepath) 
 
num=len(total_xml) 
list=range(num) 
tv=int(num*trainval_percent) 
tr=int(tv*train_percent) 
trainval= random.sample(list,tv) 
train=random.sample(trainval,tr) 
 
ftrainval = open(txtsavepath+'_trainval.txt', 'w') 
ftest = open(txtsavepath+'_test.txt', 'w') 
ftrain = open(txtsavepath+'_train.txt', 'w') 
fval = open(txtsavepath+'_val.txt', 'w') 
 
for i  in list: 
    name='/Users/sisyphus/darkflow/VOC2018/JPEGImages/'+total_xml[i][:-4]+'.jpg'+'\n' 
    if i in trainval: 
        ftrainval.write(name) 
        if i in train: 
            ftrain.write(name) 
        else: 
            fval.write(name) 
    else: 
        ftest.write(name) 
 
ftrainval.close() 
ftrain.close() 
fval.close() 
ftest .close()


txt文件中类似:
/Users/sisyphus/darkflow/VOC2018/JPEGImages/000191.jpg
/Users/sisyphus/darkflow/VOC2018/JPEGImages/000185.jpg
/Users/sisyphus/darkflow/VOC2018/JPEGImages/000813.jpg
/Users/sisyphus/darkflow/VOC2018/JPEGImages/000807.jpg
/Users/sisyphus/darkflow/VOC2018/JPEGImages/000152.jpg
/Users/sisyphus/darkflow/VOC2018/JPEGImages/000634.jpg
/Users/sisyphus/darkflow/VOC2018/JPEGImages/000620.jpg
/Users/sisyphus/darkflow/VOC2018/JPEGImages/000146.jpg
...


2. 这样就可以通过kmeans方法计算anchors:
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import argparse
import numpy as np
import os
import random
from tqdm import tqdm
import sklearn.cluster as cluster


def iou(x, centroids):
    dists = []
    for centroid in centroids:
        c_w, c_h = centroid
        w, h = x
        if c_w >= w and c_h >= h:
            dist = w * h / (c_w * c_h)
        elif c_w >= w and c_h <= h:
            dist = w * c_h / (w * h + (c_w - w) * c_h)
        elif c_w <= w and c_h >= h:
            dist = c_w * h / (w * h + c_w * (c_h - h))
        else:  # means both w,h are bigger than c_w and c_h respectively
            dist = (c_w * c_h) / (w * h)
        dists.append(dist)
    return np.array(dists)


def avg_iou(x, centroids):
    n, d = x.shape
    sums = 0.
    for i in range(x.shape[0]):
        # note IOU() will return array which contains IoU for each centroid and X[i]
        # slightly ineffective, but I am too lazy
        sums += max(iou(x[i], centroids))
    return sums / n


def write_anchors_to_file(centroids, distance, anchor_file):
    anchors = centroids * 416 / 32      # I do not know whi it is 416/32
    anchors = [str(i) for i in anchors.ravel()]
    print(
        "\n",
        "Cluster Result:\n",
        "Clusters:", len(centroids), "\n",
        "Average IoU:", distance, "\n",
        "Anchors:\n",
        ", ".join(anchors)
    )

    with open(anchor_file, 'w') as f:
        f.write(", ".join(anchors))
        f.write('\n%f\n' % distance)


def k_means(x, n_clusters, eps):
    init_index = [random.randrange(x.shape[0]) for _ in range(n_clusters)]
    centroids = x[init_index]

    d = old_d = []
    iterations = 0
    diff = 1e10
    c, dim = centroids.shape

    while True:
        iterations += 1
        d = np.array([1 - iou(i, centroids) for i in x])
        if len(old_d) > 0:
            diff = np.sum(np.abs(d - old_d))

        print('diff = %f' % diff)

        if diff < eps or iterations > 1000:
            print("Number of iterations took = %d" % iterations)
            print("Centroids = ", centroids)
            return centroids

        # assign samples to centroids
        belonging_centroids = np.argmin(d, axis=1)

        # calculate the new centroids
        centroid_sums = np.zeros((c, dim), np.float)
        for i in range(belonging_centroids.shape[0]):
            centroid_sums[belonging_centroids[i]] += x[i]

        for j in range(c):
            centroids[j] = centroid_sums[j] / np.sum(belonging_centroids == j)

        old_d = d.copy()


def get_file_content(fnm):
    with open(fnm) as f:
        return [line.strip() for line in f]


def main(args):
    print("Reading Data ...")

    file_list = []
    for f in args.file_list:
        file_list.extend(get_file_content(f))

    data = []
    for one_file in tqdm(file_list):
        one_file = one_file.replace('images', 'labels') \
            .replace('JPEGImages', 'labels') \
            .replace('.png', '.txt') \
            .replace('.jpg', '.txt')
        for line in get_file_content(one_file):
            clazz, xx, yy, w, h = line.split()
            data.append([float(w),float(h)])

    data = np.array(data)
    if args.engine.startswith("sklearn"):
        if args.engine == "sklearn":
            km = cluster.KMeans(n_clusters=args.num_clusters, tol=args.tol, verbose=True)
        elif args.engine == "sklearn-mini":
            km = cluster.MiniBatchKMeans(n_clusters=args.num_clusters, tol=args.tol, verbose=True)
        km.fit(data)
        result = km.cluster_centers_
        # distance = km.inertia_ / data.shape[0]
        distance = avg_iou(data, result)
    else:
        result = k_means(data, args.num_clusters, args.tol)
        distance = avg_iou(data, result)

    write_anchors_to_file(result, distance, args.output)


if "__main__" == __name__:
    parser = argparse.ArgumentParser()
    parser.add_argument('file_list', nargs='+', help='TrainList')
    parser.add_argument('--num_clusters', '-n', default=5, type=int, help='Number of Clusters')
    parser.add_argument('--output', '-o', default='/Users/sisyphus/darkflow/VOC2018/anchor.txt', type=str, help='Result Output File')
    parser.add_argument('--tol', '-t', default=0.005, type=float, help='Tolerate')
    parser.add_argument('--engine', '-m', default='sklearn', type=str,
                        choices=['original', 'sklearn', 'sklearn-mini'], help='Method to use')

    args = parser.parse_args()

    main(args)

cd到darkflow文件夹,终端命令行:

python anchors.py /Users/sisyphus/darkflow/VOC2018/ImageSets/Main/train.txt

得到结果:
Cluster Result:
 Clusters: 5 
 Average IoU: 0.5959804798056495 
 Anchors:

 2.838930446194225, 11.596443569553825, 9.612902298850576, 3.9339942528735645, 4.220859872611465, 6.363582802547771, 10.27776450511945, 11.884573378839587, 2.344780763790667, 3.2156152758132945

2018年5月14日星期一

SSD VOC评估与训练自己的数据集


在验证VOC2007测试集时
1. 首先将数据集转换为tfrecord格式:
DATASET_DIR=./VOC2007/test/
OUTPUT_DIR=./tfrecords
python tf_convert_data.py \
    --dataset_name=pascalvoc \
    --dataset_dir=${DATASET_DIR} \
    --output_name=voc_2007_test \
    --output_dir=${OUTPUT_DIR}

调用tf_convert_data.py将test set转化成tfrecoeds:(注意:这里直接运行会碰到无法读取图片,UTF-8无法decode的Erro,解决办法是打开SSD工程—>datasets—>pascalvoc_to_tfrecords.py 。。。然后更改文件的83行读取方式为’rb’)

注意将voc_2007_train改为voc_2007_test。

2. 进行模型评估:
DATASET_DIR=./tfrecords
EVAL_DIR=./logs/
CHECKPOINT_PATH=./checkpoints/ssd_300_vgg.ckpt
python eval_ssd_network.py \
    --eval_dir=${EVAL_DIR} \
    --dataset_dir=${DATASET_DIR} \
    --dataset_name=pascalvoc_2007 \
    --dataset_split_name=test \
    --model_name=ssd_300_vgg \
    --checkpoint_path=${CHECKPOINT_PATH} \
    --batch_size=
运行以上代码报错:
TypeError: Can not convert a tuple into a Tensor or Operation.

解决方法:
打开eval_ssd_network.py文件,然后加入以下代码:
  1. def flatten(x):  
  2.     result = []  
  3.     for el in x:  
  4.          if isinstance(el, tuple):  
  5.                result.extend(flatten(el))  
  6.          else:  
  7.                result.append(el)  
  8.     return result 
下面两处地方调用:
  1. # Standard evaluation loop.  
  2.             start = time.time()  
  3.             slim.evaluation.evaluate_once(  
  4.                 master=FLAGS.master,  
  5.                 checkpoint_path=checkpoint_path,  
  6.                 logdir=FLAGS.eval_dir,  
  7.                 num_evals=num_batches,  
  8.                 eval_op=flatten(list(names_to_updates.values())), #这里也调用flatten  
  9.                 variables_to_restore=variables_to_restore,  
  10.                 session_config=config)
  11.   
  1. # Waiting loop.  
  2.             slim.evaluation.evaluation_loop(  
  3.                 master=FLAGS.master,  
  4.                 checkpoint_dir=checkpoint_path,  
  5.                 logdir=FLAGS.eval_dir,  
  6.                 num_evals=num_batches,  
  7.                 eval_op=flatten(list(names_to_updates.values())), #这里调用flatten  
  8.                 variables_to_restore=variables_to_restore,  
  9.                 eval_interval_secs=60,  
  10.                 max_number_of_evaluations=np.inf,  
  11.                 session_config=config,  
  12.                 timeout=None
2 训练自己的数据集:
voc格式的数据集制作好以后,转换成tfrecords。需要修改一下源码,
datasets\pascalvoc_common.py:
#VOC_LABELS = {
#    'none': (0, 'Background'),
#    'aeroplane': (1, 'Vehicle'),
#    'bicycle': (2, 'Vehicle'),
#    'bird': (3, 'Animal'),
#    'boat': (4, 'Vehicle'),
#    'bottle': (5, 'Indoor'),
#    'bus': (6, 'Vehicle'),
#    'car': (7, 'Vehicle'),
#    'cat': (8, 'Animal'),
#    'chair': (9, 'Indoor'),
#    'cow': (10, 'Animal'),
#    'diningtable': (11, 'Indoor'),
#    'dog': (12, 'Animal'),
#    'horse': (13, 'Animal'),
#    'motorbike': (14, 'Vehicle'),
#    'person': (15, 'Person'),
#    'pottedplant': (16, 'Indoor'),
#    'sheep': (17, 'Animal'),
#    'sofa': (18, 'Indoor'),
#    'train': (19, 'Vehicle'),
#    'tvmonitor': (20, 'Indoor'),
#}

VOC_LABELS = {
    'none': (0, 'Background'),
    'crazing': (1, 'crazing'),
    'inclusion': (2, 'inclusion'),
    'patches': (3, 'patches'),
    'pitted_surface': (4, 'pitted_surface'),
    'rolled-in_scale': (5, 'rolled-in_scale'),
    'scratches': (6, 'scratches'),
}
接着跳转到SSD-tensorflow目录下,进行tfrecords操作,我的运行命令如下:
  1. DATASET_DIR=VOCtest2018/  
  2. OUTPUT_DIR=tfrecords/  
  3. python3 tf_convert_data.py \  
  4.     --dataset_name=pascalvoc \  
  5.     --dataset_dir=${DATASET_DIR} \  
  6.     --output_name=voc_2007_train \  
  7.     --output_dir=${OUTPUT_DIR}
这样就可以进行训练了,运行的命令为:
  1. DATASET_DIR=tfrecords  
  2. TRAIN_DIR=logs/  
  3. CHECKPOINT_PATH=./checkpoints/ssd_300_vgg.ckpt  
  4. python3 train_ssd_network.py \  
  5.     --train_dir=${TRAIN_DIR} \  
  6.     --dataset_dir=${DATASET_DIR} \  
  7.     --dataset_name=pascalvoc_2007 \  
  8.     --dataset_split_name=train \  
  9.     --model_name=ssd_300_vgg \  
  10.     --checkpoint_path=${CHECKPOINT_PATH} \  
  11.     --save_summaries_secs=60 \  
  12.     --save_interval_secs=600 \  
  13.     --weight_decay=0.0005 \  
  14.     --optimizer=adam \  
  15.     --learning_rate=0.001 \  
  16.     --batch_size=16 
  17.     --device=cpu(如果在cpu机器上跑)
  18.     --data_format=NHWC(针对cpu,或者在train_ssd_network中第27行代码改)



2018年5月10日星期四

用脚本代替flow

import sys
from darkflow.cli import cliHandler
import darkflow.net.yolov2.predict

'''
python flow --model cfg/yolo-voc-6c.cfg --load bin/yolo.weights
 --train --annotation /Users/sisyphus/darkflow/VOCtest2018/Annotation
 --dataset /Users/sisyphus/darkflow/VOCtest2018/JPEGImages --gpu 1.0
 '''

def Train():
    sys.argv = ['flow', '--model', 'cfg/yolo-voc-6c.cfg', '--load', 'bin/yolo.weights', '--train']
    cliHandler(sys.argv)
   

def Predict_Image(imgdir_):
    sys.argv = ['flow','--imgdir',imgdir_,'--model','cfg/yolo-voc-6c.cfg','--load','-1','--json']
    cliHandler(sys.argv)
#    result=darkflow.net.yolov2.predict.postprocess()
#    print(result)   
   
def Predict_Camera():
    sys.argv = ['flow','--model','cfg/yolo-voc-6c.cfg','--load','-1','--demo','camera','--json']
    cliHandler(sys.argv)
   
   
if __name__=='__main__':
    Train()


#    imgdir='sample_img_test30'
#    Predict_Image(imgdir)
   
#    Predict_Camera()

计算mAP

1. 建立ground-truth文件夹,把测试集标签xml文件导入。运行convert_gt_xml.py将xml文件转换为text格式(注意加上正常图片名称对应的text)。
2. 建立predicted文件夹,把推导生成的json文件导入。运行convert_pred_darkflow_json.py将json格式转换为text格式(注意需要补齐所有测试集文件)。
3. 运行main.py函数。

2018年5月8日星期二

JPEGImages和Annotation文件夹准备

1 对JPEGImages文件内所有图片重命名:
#ChangeJpgName.py
import re
import os
import time
#str.split(string)分割字符串
#'连接符'.join(list) 将列表组成字符串
def change_name(path):
    global i
    if not os.path.isdir(path) and not os.path.isfile(path):
        return False
    if os.path.isfile(path):
        file_path = os.path.split(path) #分割出目录与文件
        lists = file_path[1].split('.') #分割出文件与文件扩展名
        file_ext = lists[-1] #取出后缀名(列表切片操作)
        img_ext = ['bmp','jpeg','gif','psd','png','jpg']
        if file_ext in img_ext:
            os.rename(path,file_path[0]+'/'+lists[0]+'_Enh.'+file_ext)
            i+=1 #注意这里的i是一个陷阱
        #或者
        #img_ext = 'bmp|jpeg|gif|psd|png|jpg'
        #if file_ext in img_ext:
        #    print('ok---'+file_ext)
    elif os.path.isdir(path):
        for x in os.listdir(path):
            print(x)
            print(os.path.join(path,x))
            change_name(os.path.join(path,x)) #os.path.join()在路径处理上很有用


#img_dir = "/Users/sisyphus/darkflow/VOCtest2018/JPEGImagesTrainAugEnh"
img_dir = '/Users/sisyphus/darkflow/VOCtest2018/testJPEG/'
#img_dir = img_dir.replace('\\','/')
start = time.time()
i = 0
change_name(img_dir)
c = time.time() - start
print('程序运行耗时:%0.2f'%(c))
print('总共处理了 %s 张图片'%(i))

2 删除文件夹里DS_store隐藏文件
#DelDS_store.py
import os, sys;

def walk(path):
    print("cd directory:"+path)
 
    for item in os.listdir(path):
        if(item == '.DS_Store'):
            global count
            count = count+1
            print("find file .Ds_Store")
            os.remove(path + '/' +item)
        else:
            if(os.path.isdir(path + '/' + item)):
                print(" " + path  + item + "  "+"is directory")
                walk(path + '/' + item)
            else:
                print(" " + path + item + "is file")



if __name__=='__main__':
    count = 0
    dir = '/Users/sisyphus/darkflow/VOCtest2018/testJPEG/'
    walk(dir)
    print("\ntotal number:" + str(count))

3 修改xml文件中对应的jpg文件名

#xmlEdit2.py
from xml.etree import ElementTree
import os

#jpgpath='/Users/sisyphus/darkflow/VOCtest2018/JPEGImages/'
jpgpath='/Users/sisyphus/darkflow/VOCtest2018/testJPEG/'
jpglist = os.listdir(jpgpath)
jpglist.sort()

#xmlpath='/Users/sisyphus/darkflow/VOCtest2018/Annotation/'
xmlpath='/Users/sisyphus/darkflow/VOCtest2018/testAnn/'
xmllist = os.listdir(xmlpath)
xmllist.sort()

i=0
for item in xmllist:
    #print(item)
    xmldoc = ElementTree.parse(xmlpath+xmllist[i])
    node = xmldoc.find('./filename')
    node.text = jpglist[i]
    xmldoc.write(xmlpath+xmllist[i])
    i=i+1
 

4 对Annotation文件中所有xml重命名(与JPEGImage各图片名字对应)
#ChangeXmlName.py
import re
import os
import time
#str.split(string)分割字符串
#'连接符'.join(list) 将列表组成字符串
def change_name(path):
    global i
    if not os.path.isdir(path) and not os.path.isfile(path):
        return False
    if os.path.isfile(path):
        file_path = os.path.split(path) #分割出目录与文件
        lists = file_path[1].split('.') #分割出文件与文件扩展名
        file_ext = lists[-1] #取出后缀名(列表切片操作)
        img_ext = ['xml']
        if file_ext in img_ext:
            os.rename(path,file_path[0]+'/'+lists[0]+'_Enh.'+file_ext)
            i+=1 #注意这里的i是一个陷阱
        #或者
        #img_ext = 'bmp|jpeg|gif|psd|png|jpg'
        #if file_ext in img_ext:
        #    print('ok---'+file_ext)
    elif os.path.isdir(path):
        for x in os.listdir(path):
            print(x)
            print(os.path.join(path,x))
            change_name(os.path.join(path,x)) #os.path.join()在路径处理上很有用


img_dir = "/Users/sisyphus/darkflow/VOCtest2018/AnnotationTrainAugEnh"
#img_dir = '/Users/sisyphus/darkflow/VOCtest2018/testAnn/'
#img_dir = img_dir.replace('\\','/')
start = time.time()
i = 0
change_name(img_dir)
c = time.time() - start
print('程序运行耗时:%0.2f'%(c))
print('总共处理了 %s 份xml'%(i))












2018年5月6日星期日

darkflow增加验证集

除了替换diff.zif四个py模块外,还需修改

1)defults.py中训练和验证集文件夹路径改为绝对路径

2)darkflow/net/help.py

def build_train_op(self):
self.framework.loss(self.out)
self.say('Building {} train op'.format(self.meta['model']))
- optimizer = self._TRAINER[self.FLAGS.trainer](self.FLAGS.lr)
+ self.learning_rate = tf.placeholder(tf.float32, shape=[])
+ optimizer = self._TRAINER[self.FLAGS.trainer](self.learning_rate)
gradients = optimizer.compute_gradients(self.framework.loss)
self.train_op = optimizer.apply_gradients(gradients)

2018年5月3日星期四

利用darkflow训练好的模型进行推导

目前先解决单张图片推导

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed May  2 17:06:39 2018

@author: sisyphus
"""

from skimage import io,transform
import tensorflow as tf
import numpy as np
import os
import time
import pickle
from multiprocessing.pool import ThreadPool
import cv2
from darkflow.utils.box import BoundBox
from darkflow.cython_utils.cy_yolo2_findboxes import box_constructor
import json


meta = {'net': {'type': '[net]', 'batch': 64, 'subdivisions': 8, 'height': 416, 'width': 416, 'channels': 3, 'momentum': 0.9, 'decay': 0.0005, 'angle': 0, 'saturation': 1.5, 'exposure': 1.5, 'hue': 0.1, 'learning_rate': 0.0001, 'max_batches': 45000, 'policy': 'steps', 'steps': '100,25000,35000', 'scales': '10,.1,.1'}, 'type': '[region]', 'anchors': [1.08, 1.19, 3.42, 4.41, 6.63, 11.38, 9.42, 5.11, 16.62, 10.52], 'bias_match': 1, 'classes': 6, 'coords': 4, 'num': 5, 'softmax': 1, 'jitter': 0.2, 'rescore': 1, 'object_scale': 5, 'noobject_scale': 1, 'class_scale': 1, 'coord_scale': 1, 'absolute': 1, 'thresh': 0.1, 'random': 0, 'model': 'cfg/yolo-voc-6c.cfg', 'inp_size': [416, 416, 3], 'out_size': [13, 13, 55], 'name': 'yolo-voc-6c', 'labels': ['crazing', 'inclusion', 'patches', 'pitted_surface', 'rolled-in_scale', 'scratches'], 'colors': [(254.0, 254.0, 254), (222.25, 190.5, 127), (190.5, 127.0, 254), (158.75, 63.5, 127), (127.0, 254.0, 254), (95.25, 190.5, 127)]}

def findboxes1(meta, net_out):#yolov2/predict
# meta
meta = meta
boxes = list()
boxes = box_constructor(meta,net_out)
return boxes

def process_box1(b, h, w, threshold):
max_indx = np.argmax(b.probs)
max_prob = b.probs[max_indx]
label = meta['labels'][max_indx]
if max_prob > threshold:
left  = int ((b.x - b.w/2.) * w)
right = int ((b.x + b.w/2.) * w)
top   = int ((b.y - b.h/2.) * h)
bot   = int ((b.y + b.h/2.) * h)
if left  < 0    :  left = 0
if right > w - 1: right = w - 1
if top   < 0    :   top = 0
if bot   > h - 1:   bot = h - 1
mess = '{}'.format(label)
return (left, right, top, bot, mess, max_indx, max_prob)
return None

def postprocess1(net_out, im, meta, path1, outpath, save = True):
"""
Takes net output, draw net_out, save to disk
"""
boxes = findboxes1(meta, net_out)

# meta
meta = meta
threshold = meta['thresh']
colors = meta['colors']
labels = meta['labels']
if type(im) is not np.ndarray:
imgcv = cv2.imread(im)
else: imgcv = im
h, w, _ = imgcv.shape

resultsForJSON = []
for b in boxes:
boxResults = process_box1(b, h, w, threshold)
if boxResults is None:
continue
left, right, top, bot, mess, max_indx, confidence = boxResults
area=(bot-top)*(right-left)#####+
thick = int((h + w) // 300)
resultsForJSON.append({"label": mess, "confidence": float('%.2f' % confidence), "topleft": {"x": left, "y": top}, "bottomright": {"x": right, "y": bot},"area":area})

cv2.rectangle(imgcv,
(left, top), (right, bot),
colors[max_indx], thick)
cv2.putText(imgcv, mess, (left, top - 12),
0, 1e-3 * h, colors[max_indx],thick//3)

if not save: return imgcv###########

outfolder = os.path.join(outpath, 'output1')   
img_name = os.path.join(outfolder, os.path.basename(path1))
cv2.imwrite(img_name, imgcv)#####   
if True:
if resultsForJSON == []:
print('Normal\n')
# return 'Normal'
else:
textJSON = json.dumps(resultsForJSON)
textFile = os.path.splitext(img_name)[0] + ".json"
print(textFile)
print('\n')
with open(textFile, 'w') as f:
f.write(textJSON)
# return textJSON


def read_one_image(path):
    img = io.imread(path) 
    imsz = cv2.resize(img, (416, 416))
    imsz = imsz / 255.
    imsz = imsz[:,:,::-1]
    return imsz   
   
   
   
path1 = "/Users/sisyphus/darkflow/sample_img/000600.jpg"#原始图片存放地址
outpath = "/Users/sisyphus/darkflow/sample_img/"#检测结果存放地址
im = io.imread(path1)

w=416
h=416
c=3 

with tf.Session() as sess:
    data = []
    data1 = read_one_image(path1)
    data.append(data1)

    saver = tf.train.import_meta_graph('/Users/sisyphus/darkflow/ckpt/yolo-voc-6c-61125.meta')
    saver.restore(sess,tf.train.latest_checkpoint('/Users/sisyphus/darkflow/ckpt/'))
    graph = tf.get_default_graph()
    input = graph.get_tensor_by_name("input:0")
    print(input)
    feed_dict = {input:data}
    logits = graph.get_tensor_by_name("output:0")
    print(logits)
    result = sess.run(logits,feed_dict)
    netout = np.squeeze(result, axis=(0,))
    postprocess1(netout, im, meta, path1, outpath)
 

   
   

Failed to find TIFF library

ImportError: Failed to find TIFF library. Make sure that libtiff is installed and its location is listed in PATH|LD_LIBRARY_PATH|.. 解决方法: ...