Untitled.ipynb 8.9 KB
Notebook
Newer Older
C
cuicheng01 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240
{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "7a4812c2",
   "metadata": {},
   "source": [
    "# Lite预测功能测试\n",
    "\n",
    "Lite预测功能测试的主程序为`test_lite.sh`,可以测试基于Lite预测库的模型推理功能。\n",
    "\n",
    "## 1. 测试结论汇总\n",
    "\n",
    "目前Lite端的样本间支持以下四种方式的组合,共16个链条:\n",
    "\n",
    "| 模型类型 | 样本数量 | 功耗模式 | cpu多线程 |\n",
    "|  ----   |   ----   |  :----:  |  :----:  |\n",
    "| 正常模型 | 单样本/多样本 | LITE_POWER_HIGH/LITE_POWER_LOW | 支持 |\n",
    "| 正常模型 | 单样本/多样本 | LITE_POWER_HIGH/LITE_POWER_LOW | 支持 |\n",
    "| 量化模型 | 单样本/多样本 | LITE_POWER_HIGH/LITE_POWER_LOW | 支持 |\n",
    "| 量化模型 | 单样本/多样本 | LITE_POWER_HIGH/LITE_POWER_LOW | 支持 |\n",
    "\n",
    "## 2. 测试流程\n",
    "\n",
    "### 2.1 功能测试\n",
    "\n",
    "先运行`prepare.sh`准备数据和模型,模型和数据会打包到test_lite.tar中,将test_lite.tar上传到手机上,然后运行`test_lite.sh`进行测试,最终在`test_lite/output`目录下生成`lite_*.log`后缀的日志文件。\n",
    "\n",
    "```shell\n",
    "\n",
    "# 数据和模型准备\n",
    "bash PTDN/prepare.sh ./PTDN/configs/ppocr_det_mobile_params.txt \"lite_infer\"\n",
    "\n",
    "# 手机端测试:\n",
    "bash PTND/test_lite.sh ./PTDN/configs/ppocr_det_mobile_params.txt\n",
    "\n",
    "```  \n",
    "\n",
    "**注意**:数据上传到手机的方式有两种,一种是通过adb的方式通过数据线连接,可以参考[Lite端部署文档](https://github.com/PaddlePaddle/PaddleOCR/blob/develop/deploy/lite/readme.md)。另外一种是通过在手机上开启虚拟终端在局域网内通过ssh的方式连接,无需数据线,第二种方式可以在手机上支持大部分linux命令,如vim、bash等,比较推荐,可以参考[安卓手机通过termux连接电脑](./termux_for_android.md)。\n",
    "\n",
    "#### 运行结果\n",
    "\n",
    "各测试的运行情况会打印在 `./output/` 中:\n",
    "运行成功时会输出:\n",
    "\n",
    "```\n",
    "Run successfully with command - ./ocr_db_crnn det ./models/ch_ppocr_mobile_v2.0_det_slim_opt.nb INT8 4 1 LITE_POWER_LOW ./test_data/icdar2015_lite/text_localization/ch4_test_images/img_233.jpg ./config.txt True > ./output/lite_ch_ppocr_mobile_v2.0_det_slim_opt.nb_precision_INT8_batchsize_1_threads_4_powermode_LITE_POWER_LOW_singleimg_True.log 2>&1!\n",
    "Run successfully with command xxx\n",
    "...\n",
    "```\n",
    "\n",
    "运行失败时会输出:\n",
    "\n",
    "```\n",
    "Run failed with command - ./ocr_db_crnn det ./models/ch_ppocr_mobile_v2.0_det_slim_opt.nb INT8 4 1 LITE_POWER_LOW ./test_data/icdar2015_lite/text_localization/ch4_test_images/img_233.jpg ./config.txt True > ./output/lite_ch_ppocr_mobile_v2.0_det_slim_opt.nb_precision_INT8_batchsize_1_threads_4_powermode_LITE_POWER_LOW_singleimg_True.log 2>&1!\n",
    "Run failed with command xxx\n",
    "...\n",
    "```\n",
    "\n",
    "在./output/文件夹下,会存在如下日志,每一个日志都是不同配置下的log结果:\n",
    "\n",
    "<img src=\"lite_log.png\" width=\"1000\">\n",
    "\n",
    "在每一个log中,都会调用autolog打印如下信息:\n",
    "\n",
    "<img src=\"lite_auto_log.png\" width=\"1000\">\n",
    "\n",
    "\n",
    "\n",
    "## 3. 更多教程\n",
    "\n",
    "本文档为功能测试用,更详细的Lite端预测使用教程请参考:[Lite端部署](https://github.com/PaddlePaddle/PaddleOCR/blob/develop/deploy/lite/readme.md)  "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "005fdd25",
   "metadata": {},
   "source": [
    "# 安卓手机通过Termux连接电脑\n",
    "\n",
    "由于通过adb方式连接手机后,很多linux命令无法运行,自动化测试受阻,所以此处特此介绍另外一种通过Termux的连接方式,不仅可以运行大部分linux命令,方便开发者在手机上在线调试,甚至还可以多实现台机器同时连接手机。Termux不是真实的Linux环境,但是Termux可以安装真实的Linux,而且不会损失性能,与此同时,Termux不需要root。在配置Termux之前,请确保电脑已经安装adb工具,安装方式请参考[Lite端部署](https://github.com/PaddlePaddle/PaddleOCR/blob/develop/deploy/lite/readme.md) 。在运行以下命令后确保可以显示安卓设备信息。\n",
    "\n",
    "```\n",
    "adb devices\n",
    "```\n",
    "连接成功信息提示:\n",
    "```\n",
    "List of devices attached\n",
    "744be294    device\n",
    "```\n",
    "\n",
    "## 1.安卓手机安装termux app\n",
    "\n",
    "### 1.1 下载termux apk文件\n",
    "\n",
    "由于目前该app目前各大商城暂无,所以可以直接下载如下apk文件。\n",
    "\n",
    "打开电脑终端,执行以下命令:\n",
    "\n",
    "```\n",
    "wget http://10.12.121.133:8911/cuicheng01/fullchain/termux-v1.0.3.apk\n",
    "```\n",
    "\n",
    "### 1.2 安装termux到手机上\n",
    "\n",
    "在手机端的开发者模式下,允许USB调试,允许USB安装。在电脑终端,执行如下命令,将termux app安装到手机上:\n",
    "\n",
    "```\n",
    "adb install termux-v1.0.3.apk\n",
    "```\n",
    "\n",
    "此处需要手机端确认安装,点击确认。\n",
    "\n",
    "### 1.3 验证是否安装成功\n",
    "\n",
    "打开手机,检验termux是否安装成功,如果没有,重新执行1.2,如果有相应的app,点击进入,会有如下显示。\n",
    "\n",
    "<img src=\"termux.jpg\" width=\"300\" height = \"300\">\n",
    "\n",
    "接下来的配置环境需要在手机上此终端运行相关命令。\n",
    "\n",
    "## 2.手机端配置termux\n",
    "\n",
    "首先将手机联网,最好可以连接外网,部分的配置需要外网。打开Termux终端,执行以下命令安装基础件`proot`,并使用`termux-chroot`命令可以模拟 root 环境与标准的 Linux 目录结构。\n",
    "\n",
    "```\n",
    "pkg i -y proot\n",
    "termux-chroot\n",
    "```\n",
    "\n",
    "Termux 默认只能访问自身内部的数据,如果要访问手机中其它的数据,输入下面的命令后,手机弹出对请求权限的窗口,允许即可(方便对部分运行出的结果在手机端可视化)。\n",
    "\n",
    "```\n",
    "termux-setup-storage\n",
    "```\n",
    "\n",
    "### 2.1 配置SSH\n",
    "\n",
    "作为 Linux 终端或者服务器,必须有SSH。不管你是 SSH 连接到 Termux还是使用Termux去连其它主机,都需要先安装openssh。如果安装失败,请重复执行命令。\n",
    "\n",
    "```\n",
    "pkg i -y openssh\n",
    "```\n",
    "\n",
    "启动 SSH 服务端,默认端口号为8022\n",
    "\n",
    "```\n",
    "sshd\n",
    "```\n",
    "\n",
    "\n",
    "### 2.2 电脑通过SSH方式连接手机\n",
    "\n",
    "1.保证手机和电脑处于同一局域网下\n",
    "手机端分别输入以下命令获得ip地址和当前用户:\n",
    "\n",
    "```\n",
    "# 获取ip地址\n",
    "ifconfig\n",
    "\n",
    "# 获取当前用户\n",
    "whoami\n",
    "```\n",
    "\n",
    "如获取到的ip地址和当前用户分别是`172.24.162.117`和`u0_a374`。\n",
    "\n",
    "2.电脑端通过SSH连接手机\n",
    "\n",
    "```\n",
    "#默认端口号为8022\n",
    "ssh u0_a374@172.24.162.117 -p 8022\n",
    "```\n",
    "\n",
    "3.运行ls命令后,会有如下显示:\n",
    "\n",
    "```\n",
    "ls\n",
    "```\n",
    "\n",
    "<img src=\"ssh_termux_ls.png\" width=\"800\">\n",
    "\n",
    "\n",
    "### 2.3 通过scp传输数据\n",
    "\n",
    "1.在当前目录上新建test目录\n",
    "\n",
    "```\n",
    "mkdir test\n",
    "```\n",
    "\n",
    "2.测试scp功能\n",
    "\n",
    "将电脑中的某个文件拷贝到手机上:\n",
    "```\n",
    "scp -P 8022 test.txt u0_a374@172.24.162.117:/home/storage/test\n",
    "```\n",
    "\n",
    "3.手机端查看\n",
    "\n",
    "打开手机终端,在`/home/storage/test`下查看是否存在`test.txt`\n",
    "\n",
    "\n",
    "## 3. 更多教程\n",
    "\n",
    "本教程可以完成Termux基本配置,更多关于Termux的用法,请参考:[Termux高级终端安装使用配置教程](https://www.sqlsec.com/2018/05/termux.html)。\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9276a65a",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}