You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
722 lines
29 KiB
722 lines
29 KiB
|
|
<!DOCTYPE HTML>
|
|
<html lang="zh-hans" >
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
|
<title>检测算法 · GitBook</title>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
<meta name="description" content="">
|
|
<meta name="generator" content="GitBook 3.2.3">
|
|
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../../gitbook/style.css">
|
|
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-splitter/splitter.css">
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-accordion/accordion.css">
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-back-to-top-button/plugin.css">
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<meta name="HandheldFriendly" content="true"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
|
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
|
|
<link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">
|
|
|
|
|
|
<link rel="next" href="APP.html" />
|
|
|
|
|
|
<link rel="prev" href="DATASET.html" />
|
|
|
|
|
|
</head>
|
|
<body>
|
|
|
|
<div class="book">
|
|
<div class="book-summary">
|
|
|
|
|
|
<div id="book-search-input" role="search">
|
|
<input type="text" placeholder="输入并搜索" />
|
|
</div>
|
|
|
|
|
|
<nav role="navigation">
|
|
|
|
|
|
|
|
<ul class="summary">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="header">目录</li>
|
|
|
|
|
|
|
|
<li class="chapter " data-level="1.1" data-path="../../">
|
|
|
|
<a href="../../">
|
|
|
|
|
|
前言
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.2" data-path="../function/">
|
|
|
|
<a href="../function/">
|
|
|
|
|
|
产品功能
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.3" data-path="./">
|
|
|
|
<a href="./">
|
|
|
|
|
|
开发技术
|
|
|
|
</a>
|
|
|
|
|
|
|
|
<ul class="articles">
|
|
|
|
|
|
<li class="chapter " data-level="1.3.1" data-path="DATASET.html">
|
|
|
|
<a href="DATASET.html">
|
|
|
|
|
|
数据集
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter active" data-level="1.3.2" data-path="ALGORITHM.html">
|
|
|
|
<a href="ALGORITHM.html">
|
|
|
|
|
|
检测算法
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.3.3" data-path="APP.html">
|
|
|
|
<a href="APP.html">
|
|
|
|
|
|
App 端构建
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
<li class="chapter " data-level="1.3.4" data-path="SERVER.html">
|
|
|
|
<a href="SERVER.html">
|
|
|
|
|
|
后端构建
|
|
|
|
</a>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
<li class="divider"></li>
|
|
|
|
<li>
|
|
<a href="https://www.gitbook.com" target="blank" class="gitbook-link">
|
|
本书使用 GitBook 发布
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
|
|
|
|
</nav>
|
|
|
|
|
|
</div>
|
|
|
|
<div class="book-body">
|
|
|
|
<div class="body-inner">
|
|
|
|
|
|
|
|
<div class="book-header" role="navigation">
|
|
|
|
|
|
<!-- Title -->
|
|
<h1>
|
|
<i class="fa fa-circle-o-notch fa-spin"></i>
|
|
<a href="../.." >检测算法</a>
|
|
</h1>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="page-wrapper" tabindex="-1" role="main">
|
|
<div class="page-inner">
|
|
|
|
<div id="book-search-results">
|
|
<div class="search-noresults">
|
|
|
|
<section class="normal markdown-section">
|
|
|
|
<h3 id="深度可分离卷积检测算法">深度可分离卷积检测算法</h3>
|
|
<p>Language: Python</p>
|
|
<p>使用TensorFlow 深度学习框架,使用Keras会大幅缩减代码量</p>
|
|
<p>训练机器:华为Atlas 200 AI开发板(或本地计算机)</p>
|
|
<p><a href="../../../medicine-dataset">数据集</a></p>
|
|
<p>常用的<strong>卷积网络模型</strong>及在ImageNet上的准确率</p>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th style="text-align:center">模型</th>
|
|
<th style="text-align:center">大小</th>
|
|
<th style="text-align:center">Top-1准确率</th>
|
|
<th style="text-align:center">Top-5准确率</th>
|
|
<th style="text-align:center">参数数量</th>
|
|
<th style="text-align:center">深度</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td style="text-align:center">Xception</td>
|
|
<td style="text-align:center">88 MB</td>
|
|
<td style="text-align:center">0.790</td>
|
|
<td style="text-align:center">0.945</td>
|
|
<td style="text-align:center">22,910,480</td>
|
|
<td style="text-align:center">126</td>
|
|
</tr>
|
|
<tr>
|
|
<td style="text-align:center">VGG16</td>
|
|
<td style="text-align:center">528 MB</td>
|
|
<td style="text-align:center">0.713</td>
|
|
<td style="text-align:center">0.901</td>
|
|
<td style="text-align:center">138,357,544</td>
|
|
<td style="text-align:center">23</td>
|
|
</tr>
|
|
<tr>
|
|
<td style="text-align:center">VGG19</td>
|
|
<td style="text-align:center">549 MB</td>
|
|
<td style="text-align:center">0.713</td>
|
|
<td style="text-align:center">0.900</td>
|
|
<td style="text-align:center">143,667,240</td>
|
|
<td style="text-align:center">26</td>
|
|
</tr>
|
|
<tr>
|
|
<td style="text-align:center">ResNet50</td>
|
|
<td style="text-align:center">98 MB</td>
|
|
<td style="text-align:center">0.749</td>
|
|
<td style="text-align:center">0.921</td>
|
|
<td style="text-align:center">25,636,712</td>
|
|
<td style="text-align:center">168</td>
|
|
</tr>
|
|
<tr>
|
|
<td style="text-align:center">ResNet101</td>
|
|
<td style="text-align:center">171 MB</td>
|
|
<td style="text-align:center">0.764</td>
|
|
<td style="text-align:center">0.928</td>
|
|
<td style="text-align:center">44,707,176</td>
|
|
<td style="text-align:center">-</td>
|
|
</tr>
|
|
<tr>
|
|
<td style="text-align:center">ResNet152</td>
|
|
<td style="text-align:center">232 MB</td>
|
|
<td style="text-align:center">0.766</td>
|
|
<td style="text-align:center">0.931</td>
|
|
<td style="text-align:center">60,419,944</td>
|
|
<td style="text-align:center">-</td>
|
|
</tr>
|
|
<tr>
|
|
<td style="text-align:center">ResNet50V2</td>
|
|
<td style="text-align:center">98 MB</td>
|
|
<td style="text-align:center">0.760</td>
|
|
<td style="text-align:center">0.930</td>
|
|
<td style="text-align:center">25,613,800</td>
|
|
<td style="text-align:center">-</td>
|
|
</tr>
|
|
<tr>
|
|
<td style="text-align:center">ResNet101V2</td>
|
|
<td style="text-align:center">171 MB</td>
|
|
<td style="text-align:center">0.772</td>
|
|
<td style="text-align:center">0.938</td>
|
|
<td style="text-align:center">44,675,560</td>
|
|
<td style="text-align:center">-</td>
|
|
</tr>
|
|
<tr>
|
|
<td style="text-align:center">ResNet152V2</td>
|
|
<td style="text-align:center">232 MB</td>
|
|
<td style="text-align:center">0.780</td>
|
|
<td style="text-align:center">0.942</td>
|
|
<td style="text-align:center">60,380,648</td>
|
|
<td style="text-align:center">-</td>
|
|
</tr>
|
|
<tr>
|
|
<td style="text-align:center">ResNeXt50</td>
|
|
<td style="text-align:center">96 MB</td>
|
|
<td style="text-align:center">0.777</td>
|
|
<td style="text-align:center">0.938</td>
|
|
<td style="text-align:center">25,097,128</td>
|
|
<td style="text-align:center">-</td>
|
|
</tr>
|
|
<tr>
|
|
<td style="text-align:center">ResNeXt101</td>
|
|
<td style="text-align:center">170 MB</td>
|
|
<td style="text-align:center">0.787</td>
|
|
<td style="text-align:center">0.943</td>
|
|
<td style="text-align:center">44,315,560</td>
|
|
<td style="text-align:center">-</td>
|
|
</tr>
|
|
<tr>
|
|
<td style="text-align:center">InceptionV3</td>
|
|
<td style="text-align:center">92 MB</td>
|
|
<td style="text-align:center">0.779</td>
|
|
<td style="text-align:center">0.937</td>
|
|
<td style="text-align:center">23,851,784</td>
|
|
<td style="text-align:center">159</td>
|
|
</tr>
|
|
<tr>
|
|
<td style="text-align:center">InceptionResNetV2</td>
|
|
<td style="text-align:center">215 MB</td>
|
|
<td style="text-align:center">0.803</td>
|
|
<td style="text-align:center">0.953</td>
|
|
<td style="text-align:center">55,873,736</td>
|
|
<td style="text-align:center">572</td>
|
|
</tr>
|
|
<tr>
|
|
<td style="text-align:center">MobileNet</td>
|
|
<td style="text-align:center">16 MB</td>
|
|
<td style="text-align:center">0.704</td>
|
|
<td style="text-align:center">0.895</td>
|
|
<td style="text-align:center">4,253,864</td>
|
|
<td style="text-align:center">88</td>
|
|
</tr>
|
|
<tr>
|
|
<td style="text-align:center">MobileNetV2</td>
|
|
<td style="text-align:center">14 MB</td>
|
|
<td style="text-align:center">0.713</td>
|
|
<td style="text-align:center">0.901</td>
|
|
<td style="text-align:center">3,538,984</td>
|
|
<td style="text-align:center">88</td>
|
|
</tr>
|
|
<tr>
|
|
<td style="text-align:center">DenseNet121</td>
|
|
<td style="text-align:center">33 MB</td>
|
|
<td style="text-align:center">0.750</td>
|
|
<td style="text-align:center">0.923</td>
|
|
<td style="text-align:center">8,062,504</td>
|
|
<td style="text-align:center">121</td>
|
|
</tr>
|
|
<tr>
|
|
<td style="text-align:center">DenseNet169</td>
|
|
<td style="text-align:center">57 MB</td>
|
|
<td style="text-align:center">0.762</td>
|
|
<td style="text-align:center">0.932</td>
|
|
<td style="text-align:center">14,307,880</td>
|
|
<td style="text-align:center">169</td>
|
|
</tr>
|
|
<tr>
|
|
<td style="text-align:center">DenseNet201</td>
|
|
<td style="text-align:center">80 MB</td>
|
|
<td style="text-align:center">0.773</td>
|
|
<td style="text-align:center">0.936</td>
|
|
<td style="text-align:center">20,242,984</td>
|
|
<td style="text-align:center">201</td>
|
|
</tr>
|
|
<tr>
|
|
<td style="text-align:center">NASNetMobile</td>
|
|
<td style="text-align:center">23 MB</td>
|
|
<td style="text-align:center">0.744</td>
|
|
<td style="text-align:center">0.919</td>
|
|
<td style="text-align:center">5,326,716</td>
|
|
<td style="text-align:center">-</td>
|
|
</tr>
|
|
<tr>
|
|
<td style="text-align:center">NASNetLarge</td>
|
|
<td style="text-align:center">343 MB</td>
|
|
<td style="text-align:center">0.825</td>
|
|
<td style="text-align:center">0.960</td>
|
|
<td style="text-align:center">88,949,818</td>
|
|
<td style="text-align:center">-</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>由于硬件条件限制,综合考虑模型的准确率、大小以及复杂度等因素,采用了<strong>Xception模型</strong>,
|
|
该模型是134层(包含激活层,批标准化层等)拓扑深度的卷积网络模型。</p>
|
|
<h2 id="检测算法">检测算法</h2>
|
|
<pre><code class="lang-python">def Xception(include_top=True,
|
|
weights='imagenet',
|
|
input_tensor=None,
|
|
input_shape=None,
|
|
pooling=None,
|
|
classes=1000,
|
|
**kwargs)
|
|
|
|
# 参数
|
|
# include_top:是否保留顶层的全连接网络
|
|
# weights:None代表随机初始化,即不加载预训练权重。'imagenet’代表加载预训练权重
|
|
# input_tensor:可填入Keras tensor作为模型的图像输入tensor
|
|
# input_shape:可选,仅当include_top=False有效,应为长为3的tuple,指明输入图片的shape,图片的宽高必须大于71,如(150,150,3)
|
|
# pooling:当include_top=False时,该参数指定了池化方式。None代表不池化,最后一个卷积层的输出为4D张量。‘avg’代表全局平均池化,‘max’代表全局最大值池化。
|
|
# classes:可选,图片分类的类别数,仅当include_top=True并且不加载预训练权重时可用
|
|
</code></pre>
|
|
<p><a href="../../../medicine-model/src">基于Xception的模型微调,详细请参考代码</a></p>
|
|
<ol>
|
|
<li><p>设置Xception参数</p>
|
|
<p> 迁移学习参数权重加载:xception_weights</p>
|
|
<pre><code class="lang-python"> <span class="hljs-comment"># 设置输入图像的宽高以及通道数</span>
|
|
img_size = (<span class="hljs-number">299</span>, <span class="hljs-number">299</span>, <span class="hljs-number">3</span>)
|
|
|
|
base_model = keras.applications.xception.Xception(include_top=<span class="hljs-keyword">False</span>,
|
|
weights=<span class="hljs-string">'..\\resources\\keras-model\\xception_weights_tf_dim_ordering_tf_kernels_notop.h5'</span>,
|
|
input_shape=img_size,
|
|
pooling=<span class="hljs-string">'avg'</span>)
|
|
|
|
<span class="hljs-comment"># 全连接层,使用softmax激活函数计算概率值,分类大小是628</span>
|
|
model = keras.layers.Dense(<span class="hljs-number">628</span>, activation=<span class="hljs-string">'softmax'</span>, name=<span class="hljs-string">'predictions'</span>)(base_model.output)
|
|
model = keras.Model(base_model.input, model)
|
|
|
|
<span class="hljs-comment"># 锁定卷积层</span>
|
|
<span class="hljs-keyword">for</span> layer <span class="hljs-keyword">in</span> base_model.layers:
|
|
layer.trainable = <span class="hljs-keyword">False</span>
|
|
</code></pre>
|
|
</li>
|
|
<li><p>全连接层训练(v1.0)</p>
|
|
<pre><code class="lang-python"> <span class="hljs-keyword">from</span> base_model <span class="hljs-keyword">import</span> model
|
|
|
|
<span class="hljs-comment"># 设置训练集图片大小以及目录参数</span>
|
|
img_size = (<span class="hljs-number">299</span>, <span class="hljs-number">299</span>)
|
|
dataset_dir = <span class="hljs-string">'..\\dataset\\dataset'</span>
|
|
img_save_to_dir = <span class="hljs-string">'resources\\image-traing\\'</span>
|
|
log_dir = <span class="hljs-string">'resources\\train-log'</span>
|
|
|
|
model_dir = <span class="hljs-string">'resources\\keras-model\\'</span>
|
|
|
|
<span class="hljs-comment"># 使用数据增强</span>
|
|
train_datagen = keras.preprocessing.image.ImageDataGenerator(
|
|
rescale=<span class="hljs-number">1.</span> / <span class="hljs-number">255</span>,
|
|
shear_range=<span class="hljs-number">0.2</span>,
|
|
width_shift_range=<span class="hljs-number">0.4</span>,
|
|
height_shift_range=<span class="hljs-number">0.4</span>,
|
|
rotation_range=<span class="hljs-number">90</span>,
|
|
zoom_range=<span class="hljs-number">0.7</span>,
|
|
horizontal_flip=<span class="hljs-keyword">True</span>,
|
|
vertical_flip=<span class="hljs-keyword">True</span>,
|
|
preprocessing_function=keras.applications.xception.preprocess_input)
|
|
|
|
test_datagen = keras.preprocessing.image.ImageDataGenerator(
|
|
preprocessing_function=keras.applications.xception.preprocess_input)
|
|
|
|
train_generator = train_datagen.flow_from_directory(
|
|
dataset_dir,
|
|
save_to_dir=img_save_to_dir,
|
|
target_size=img_size,
|
|
class_mode=<span class="hljs-string">'categorical'</span>)
|
|
|
|
validation_generator = test_datagen.flow_from_directory(
|
|
dataset_dir,
|
|
save_to_dir=img_save_to_dir,
|
|
target_size=img_size,
|
|
class_mode=<span class="hljs-string">'categorical'</span>)
|
|
|
|
<span class="hljs-comment"># 早停法以及动态学习率设置</span>
|
|
early_stop = EarlyStopping(monitor=<span class="hljs-string">'val_loss'</span>, patience=<span class="hljs-number">13</span>)
|
|
reduce_lr = ReduceLROnPlateau(monitor=<span class="hljs-string">'val_loss'</span>, patience=<span class="hljs-number">7</span>, mode=<span class="hljs-string">'auto'</span>, factor=<span class="hljs-number">0.2</span>)
|
|
tensorboard = keras.callbacks.tensorboard_v2.TensorBoard(log_dir=log_dir)
|
|
|
|
<span class="hljs-keyword">for</span> layer <span class="hljs-keyword">in</span> model.layers:
|
|
layer.trainable = <span class="hljs-keyword">False</span>
|
|
|
|
<span class="hljs-comment"># 模型编译</span>
|
|
model.compile(optimizer=<span class="hljs-string">'rmsprop'</span>, loss=<span class="hljs-string">'categorical_crossentropy'</span>, metrics=[<span class="hljs-string">'accuracy'</span>])
|
|
|
|
history = model.fit_generator(train_generator,
|
|
steps_per_epoch=train_generator.samples // train_generator.batch_size,
|
|
epochs=<span class="hljs-number">100</span>,
|
|
validation_data=validation_generator,
|
|
validation_steps=validation_generator.samples // validation_generator.batch_size,
|
|
callbacks=[early_stop, reduce_lr, tensorboard])
|
|
<span class="hljs-comment"># 模型导出</span>
|
|
model.save(model_dir + <span class="hljs-string">'chinese_medicine_model_v1.0.h5'</span>)
|
|
</code></pre>
|
|
</li>
|
|
<li><p>对于顶部的6层卷积层,我们使用数据集对权重参数进行微调</p>
|
|
<pre><code class="lang-python"> <span class="hljs-comment"># 加载模型</span>
|
|
model=keras.models.load_model(<span class="hljs-string">'resources\\keras-model\\chinese_medicine_model_v2.0.h5'</span>)
|
|
|
|
<span class="hljs-keyword">for</span> layer <span class="hljs-keyword">in</span> model.layers:
|
|
layer.trainable = <span class="hljs-keyword">False</span>
|
|
<span class="hljs-keyword">for</span> layer <span class="hljs-keyword">in</span> model.layers[<span class="hljs-number">126</span>:<span class="hljs-number">132</span>]:
|
|
layer.trainable = <span class="hljs-keyword">True</span>
|
|
|
|
history = model.fit_generator(train_generator,
|
|
steps_per_epoch=train_generator.samples // train_generator.batch_size,
|
|
epochs=<span class="hljs-number">100</span>,
|
|
validation_data=validation_generator,
|
|
validation_steps=validation_generator.samples // validation_generator.batch_size,
|
|
callbacks=[early_stop, reduce_lr, tensorboard])
|
|
model.save(model_dir + <span class="hljs-string">'chinese_medicine_model_v2.0.h5'</span>)
|
|
</code></pre>
|
|
</li>
|
|
<li><p>在后端项目中,我们使用Deeplearn4j调用训练好的模型
|
|
```
|
|
public class CnnModelUtil {</p>
|
|
<pre><code> private static ComputationGraph CNN_MODEL = null;
|
|
|
|
/**
|
|
* 中药名字的编码
|
|
*/
|
|
private static final Map<Integer, String> MEDICINE_NAME_MAP = new HashMap<>();
|
|
|
|
/**
|
|
* 定义cnn model的文件夹路径
|
|
*/
|
|
private static final String DATA_DIR = System.getProperty("os.name")
|
|
.toLowerCase().contains("windows") ? "D:\\data\\model\\"
|
|
: "./data/model/";
|
|
|
|
/**
|
|
* 定义中药编码表的文件名
|
|
*/
|
|
private static final String MEDICINE_LABLE_FILE_NAME = "medicine_name-lable.txt";
|
|
|
|
/**
|
|
* 定义模型的文件名
|
|
*/
|
|
private static final String CNN_MODEL_FILE_NAME = "chinese_medicine_model.h5";
|
|
</code></pre></li>
|
|
</ol>
|
|
<pre><code> /**
|
|
* 图片的加载器
|
|
*/
|
|
private static final NativeImageLoader IMAGE_LOADER = new NativeImageLoader(299, 299, 3);
|
|
|
|
|
|
/**
|
|
* 初始化
|
|
*/
|
|
static {
|
|
try {
|
|
CNN_MODEL = KerasModelImport.importKerasModelAndWeights(DATA_DIR + CNN_MODEL_FILE_NAME);
|
|
|
|
Files.readAllLines(Paths.get(DATA_DIR, MEDICINE_LABLE_FILE_NAME)).forEach(v -> {
|
|
String[] split = v.split(",");
|
|
MEDICINE_NAME_MAP.put(Integer.valueOf(split[1]), split[0]);
|
|
});
|
|
} catch (IOException | InvalidKerasConfigurationException | UnsupportedKerasConfigurationException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 对图像进行预测
|
|
* 对预测的概率值进行排序处理
|
|
* 返回值是概率值前10的中药的名字
|
|
* @param file
|
|
* @return
|
|
* @throws
|
|
*/
|
|
public static Map<String, Float> medicineNamePredict(File file) throws IOException {
|
|
INDArray image = IMAGE_LOADER.asMatrix(file).divi(127.5).subi(1);
|
|
INDArray output = CNN_MODEL.outputSingle(image);
|
|
Map<Integer, Float> resultMap = new HashMap<>();
|
|
float[] floats = output.toFloatVector();
|
|
for (int i = 0; i < floats.length; i++) {
|
|
resultMap.put(i, floats[i]);
|
|
}
|
|
List<Map.Entry<Integer, Float>> resultList = new LinkedList<>(resultMap.entrySet());
|
|
resultList.sort(Map.Entry.comparingByValue(Comparator.reverseOrder()));
|
|
Map<String, Float> medicinePredict = new LinkedHashMap<>();
|
|
resultList.stream().limit(10).forEach(v -> {
|
|
medicinePredict.put(MEDICINE_NAME_MAP.get(v.getKey()), v.getValue());
|
|
});
|
|
return medicinePredict;
|
|
}
|
|
}
|
|
```
|
|
</code></pre><h3 id="模型概览">模型概览</h3>
|
|
<p><a href="../../assets/images/model.png">模型详细结构</a></p>
|
|
<p><strong>训练过程正确率以及损失函数可视化展示</strong></p>
|
|
<p><img src="../../assets/images/正确率.png" alt="正确率">
|
|
<img src="../../assets/images/损失函数.png" alt="损失函数"></p>
|
|
|
|
|
|
</section>
|
|
|
|
</div>
|
|
<div class="search-results">
|
|
<div class="has-results">
|
|
|
|
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
|
|
<ul class="search-results-list"></ul>
|
|
|
|
</div>
|
|
<div class="no-results">
|
|
|
|
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<a href="DATASET.html" class="navigation navigation-prev " aria-label="Previous page: 数据集">
|
|
<i class="fa fa-angle-left"></i>
|
|
</a>
|
|
|
|
|
|
<a href="APP.html" class="navigation navigation-next " aria-label="Next page: App 端构建">
|
|
<i class="fa fa-angle-right"></i>
|
|
</a>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<script>
|
|
var gitbook = gitbook || [];
|
|
gitbook.push(function() {
|
|
gitbook.page.hasChanged({"page":{"title":"检测算法","level":"1.3.2","depth":2,"next":{"title":"App 端构建","level":"1.3.3","depth":2,"path":"docs/technology/APP.md","ref":"docs/technology/APP.md","articles":[]},"previous":{"title":"数据集","level":"1.3.1","depth":2,"path":"docs/technology/DATASET.md","ref":"docs/technology/DATASET.md","articles":[]},"dir":"ltr"},"config":{"plugins":["splitter","copy-code-button","highlight","accordion","back-to-top-button"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"splitter":{},"accordion":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"back-to-top-button":{},"copy-code-button":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"language":"zh-hans","links":{},"gitbook":"*"},"file":{"path":"docs/technology/ALGORITHM.md","mtime":"2021-04-02T04:05:01.247Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-04-02T08:17:55.461Z"},"basePath":"../..","book":{"language":""}});
|
|
});
|
|
</script>
|
|
</div>
|
|
|
|
|
|
<script src="../../gitbook/gitbook.js"></script>
|
|
<script src="../../gitbook/theme.js"></script>
|
|
|
|
|
|
<script src="../../gitbook/gitbook-plugin-splitter/splitter.js"></script>
|
|
|
|
|
|
|
|
<script src="../../gitbook/gitbook-plugin-copy-code-button/toggle.js"></script>
|
|
|
|
|
|
|
|
<script src="../../gitbook/gitbook-plugin-accordion/accordionSelector.js"></script>
|
|
|
|
|
|
|
|
<script src="../../gitbook/gitbook-plugin-back-to-top-button/plugin.js"></script>
|
|
|
|
|
|
|
|
<script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
|
|
|
|
|
|
|
|
<script src="../../gitbook/gitbook-plugin-search/search.js"></script>
|
|
|
|
|
|
|
|
<script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
|
|
|
|
|
|
|
|
<script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
|
|
|
|
|
|
|
|
<script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
|
|
|
|
|
|
|
|
<script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
|
|
|
|
|
|
|
|
</body>
|
|
</html>
|
|
|