资源简介
keras-finetuning, 使用你自己的数据集训练基于InceptionV3的图像分类器 使用你自己的数据集训练InceptionV3-based图像分类器基于在的新集合中的微调( InceptionV3 ),在 https://keras.io/applications/中的例子依赖项最新的( 来自源的> =1.0

代码片段和文件信息
# This should be completely refactored shares a lot of code with train.py
import sys
from collections import defaultdict
import numpy as np
# It‘s very important to put this import before keras
# as explained here: Loading tensorflow before scipy.misc seems to cause imread to fail #1541
# https://github.com/tensorflow/tensorflow/issues/1541
import scipy.misc
from keras.utils import np_utils
import dataset
import net
np.random.seed(1337)
n = 224
batch_size = 128
data_directory = sys.argv[1:]
X y tags = dataset.dataset(data_directory n)
nb_classes = len(tags)
sample_count = len(y)
train_size = sample_count * 4 // 5
X_train = X[:train_size]
y_train = y[:train_size]
Y_train = np_utils.to_categorical(y_train nb_classes)
X_test = X[train_size:]
y_test = y[train_size:]
Y_test = np_utils.to_categorical(y_test nb_classes)
def evaluate(model vis_filename=None):
Y_pred = model.predict(X_test batch_size=batch_size)
y_pred = np.argmax(Y_pred axis=1)
accuracy = float(np.sum(y_test==y_pred)) / len(y_test)
print “accuracy:“ accuracy
confusion = np.zeros((nb_classes nb_classes) dtype=np.int32)
for (predicted_index actual_index image) in zip(y_pred y_test X_test):
confusion[predicted_index actual_index] += 1
print “rows are predicted classes columns are actual classes“
for predicted_index predicted_tag in enumerate(tags):
print predicted_tag[:7]
for actual_index actual_tag in enumerate(tags):
print “\t%d“ % confusion[predicted_index actual_index]
print
if vis_filename is not None:
bucket_size = 10
image_size = n // 4 # right now that‘s 56
vis_image_size = nb_classes * image_size * bucket_size
vis_image = 255 * np.ones((vis_image_size vis_image_size 3) dtype=‘uint8‘)
example_counts = defaultdict(int)
for (predicted_tag actual_tag normalized_image) in zip(y_pred y_test X_test):
example_count = example_counts[(predicted_tag actual_tag)]
if example_count >= bucket_size**2:
continue
image = dataset.reverse_preprocess_input(normalized_image)
image = image.transpose((1 2 0))
image = scipy.misc.imresize(image (image_size image_size)).astype(np.uint8)
tilepos_x = bucket_size * predicted_tag
tilepos_y = bucket_size * actual_tag
tilepos_x += example_count % bucket_size
tilepos_y += example_count // bucket_size
pos_x pos_y = tilepos_x * image_size tilepos_y * image_size
vis_image[pos_y:pos_y+image_size pos_x:pos_x+image_size :] = image
example_counts[(predicted_tag actual_tag)] += 1
vis_image[::image_size * bucket_size :] = 0
vis_image[: ::image_size * bucket_size] = 0
scipy.misc.imsave(vis_filename vis_image)
model tags_from_model = net.load(“model“)
assert tags == tags_from_model
net.compile(model)
evalua
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2016-09-13 21:12 keras-finetuning-master\
文件 3855 2016-09-13 21:12 keras-finetuning-master\README.md
文件 3028 2016-09-13 21:12 keras-finetuning-master\classify.py
文件 793 2016-09-13 21:12 keras-finetuning-master\collect-apple-photos.sh
文件 1886 2016-09-13 21:12 keras-finetuning-master\collect_apple_photos.py
文件 2202 2016-09-13 21:12 keras-finetuning-master\dataset.py
文件 930127 2016-09-13 21:12 keras-finetuning-master\haarcascade_frontalface_default.xm
文件 1852 2016-09-13 21:12 keras-finetuning-master\net.py
文件 911 2016-09-13 21:12 keras-finetuning-master\osx-install.sh
文件 6073 2016-09-13 21:12 keras-finetuning-master\train.py
文件 2301 2016-09-13 21:12 keras-finetuning-master\webcam.py
相关资源
- 开源1A锂电池充电板TP4056原理图+PCB
-
st
yles 引文样式语言( CSL ) 引文样 - 开源电调BLHeli硬件PCB 4层板 2.5cm宽
-
开源tinyxm
l - 一个比较完整的开源cad 图形程序
- 开源的nmealib
- CS1.6 透视自瞄多功能 开源.e
- SpringBoot实战(第4版)清晰版.pdf.zip
- IEC60870开源实现库
- 开源图像库leptonica头文件和库文件
- 开源自写磁盘还原
- JMeter开源性能官方书籍pdf
- 人脸识别开源SDK源码
- st官方开源的电机库foc5.0
- 原生网页封装Nativefier.zip
- 方滨兴 在线社交网络分析 方滨兴
- robomaster自动识别开源
-
优酷视频播放地址分析kupla
yer.zip - Sniffer原理及开源代码
- 国外开源视频监控iSpy源代码20180905
- 开单大师学习版3.1.2房产软件 源码 房
- 凤凰山管理系统毕设定制开源共享
- 翼型及机翼空气动力分析开源软件X
- IDCardOCR_China 基于tesseract,实现摄像头
- asn1c-0.9.24
- 极速浏览器源代码,开源中功能最强
- .net开源的维基百科系统
- 开源生态白皮书2020).pdf
- 免费开源强大的ILSpy 2.3
- 遗传算法解决TSP旅行商问题程序开源
评论
共有 条评论